<html>
<head><meta charset="utf-8"><title>Pointer authentication support in Rust&#x27;s LLVM codegen · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html">Pointer authentication support in Rust&#x27;s LLVM codegen</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204420766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204420766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204420766">(Jul 20 2020 at 13:18)</a>:</h4>
<div class="codehilite"><pre><span></span><code>   Compiling panic_abort v0.0.0 (/Users/aleister/Code/rust/src/libpanic_abort)
LLVM ERROR: arm64e LR authentication requires ptrauth
error: could not compile `panic_abort`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
LLVM ERROR: arm64e LR authentication requires ptrauth
LLVM ERROR: arm64e LR authentication requires ptrauth
error: build failed
</code></pre></div>



<a name="204421203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204421203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204421203">(Jul 20 2020 at 13:23)</a>:</h4>
<p>wait crap wrong target lmao i'm dumb</p>



<a name="204433112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204433112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204433112">(Jul 20 2020 at 15:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116155">Jake Goulding</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/How.20to.20get.20rustc.20to.20generate.20LLVM.20IR.20differently.3F/near/204380137">said</a>:</p>
<blockquote>
<p>As I mentioned earlier, I wouldn't expect there to be specific instructions in the IR (unless you had an <code>asm!</code> block)</p>
</blockquote>
<p>well,</p>



<a name="204433163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204433163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204433163">(Jul 20 2020 at 15:00)</a>:</h4>
<h3>Operand Bundle</h3>
<p>As a way to enforce CFI, function pointers used as indirect call targets are<br>
signed when materialized, and authenticated before calls.</p>
<p>To prevent the intermediate, unauthenticated pointer from being exposed to<br>
attackers (similar to <a href="#llvm-ptrauth-resign"><code>llvm.ptrauth.resign</code></a>), the<br>
representation guarantees that the intermediate call target is never attackable<br>
(e.g., by being spilled to memory), using the <code>ptrauth</code> operand bundle.</p>
<div class="codehilite"><pre><span></span><code><span class="k">define</span> <span class="k">void</span> <span class="vg">@f</span><span class="p">(</span><span class="k">void</span> <span class="p">()*</span> <span class="nv">%fp</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">call</span> <span class="k">void</span> <span class="nv">%fp</span><span class="p">()</span> <span class="p">[</span> <span class="s">&quot;ptrauth&quot;</span><span class="p">(</span><span class="k">i32</span> <span class="p">&lt;</span><span class="err">key</span><span class="p">&gt;,</span> <span class="k">i64</span> <span class="p">&lt;</span><span class="err">data</span><span class="p">&gt;)</span> <span class="p">]</span>
  <span class="k">ret</span> <span class="k">void</span>
<span class="p">}</span>
</code></pre></div>


<p>is functionally equivalent to:</p>
<div class="codehilite"><pre><span></span><code><span class="k">define</span> <span class="k">void</span> <span class="vg">@f</span><span class="p">(</span><span class="k">void</span> <span class="p">()*</span> <span class="nv">%fp</span><span class="p">)</span> <span class="p">{</span>
  <span class="nv">%fp_i</span> <span class="p">=</span> <span class="k">ptrtoint</span> <span class="k">void</span> <span class="p">()*</span> <span class="nv">%fp</span> <span class="k">to</span> <span class="k">i64</span>
  <span class="nv">%fp_auth</span> <span class="p">=</span> <span class="k">call</span> <span class="k">i64</span> <span class="vg">@llvm.ptrauth.auth.i64</span><span class="p">(</span><span class="k">i64</span> <span class="nv">%fp_i</span><span class="p">,</span> <span class="k">i32</span> <span class="p">&lt;</span><span class="err">key</span><span class="p">&gt;,</span> <span class="k">i64</span> <span class="p">&lt;</span><span class="err">data</span><span class="p">&gt;)</span>
  <span class="nv">%fp_auth_p</span> <span class="p">=</span> <span class="k">inttoptr</span> <span class="k">i64</span> <span class="nv">%fp_auth</span> <span class="k">to</span> <span class="k">void</span> <span class="p">()*</span>
  <span class="k">call</span> <span class="k">void</span> <span class="nv">%fp_auth_p</span><span class="p">()</span>
  <span class="k">ret</span> <span class="k">void</span>
<span class="p">}</span>
</code></pre></div>



<a name="204433183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204433183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204433183">(Jul 20 2020 at 15:00)</a>:</h4>
<p>that's from PointerAuth.md</p>



<a name="204433210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204433210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204433210">(Jul 20 2020 at 15:00)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="123586">@nagisa</span></p>



<a name="204436465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204436465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204436465">(Jul 20 2020 at 15:24)</a>:</h4>
<p>I don't think I'm following your point. There's a call to a function that has <code>ptrauth</code> in the name, sure, and there are <code>ptrauth</code> attributes on the <code>call</code> instruction. None of those are _instructions_ (like your mentioned <code>pacibsp</code> or <code>retab</code>). The LLVM IR instructions here are <code>ptrtoint</code>, <code>call</code>, <code>inttoptr</code>, <code>ret</code>.</p>



<a name="204461798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204461798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204461798">(Jul 20 2020 at 19:00)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> that's not a call to a function with ptrauth in it's name, that's a call to <code>%fp</code> using ptrauth. Sorry if my brain's a bit fried rn, just woke up.</p>



<a name="204461865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204461865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204461865">(Jul 20 2020 at 19:01)</a>:</h4>
<p><a href="https://github.com/apple/llvm-project/blob/apple/stable/20200108/llvm/docs/PointerAuth.md">https://github.com/apple/llvm-project/blob/apple/stable/20200108/llvm/docs/PointerAuth.md</a></p>



<a name="204461885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204461885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204461885">(Jul 20 2020 at 19:01)</a>:</h4>
<p>ptrauth-calls</p>
<p>ptrauth-calls specifies that calls emitted in this function should be authenticated according to the platform ABI.</p>
<p><strong>Calls represented by call/invoke instructions in IR are not affected by this attribute, as they should already be annotated with the <code>ptrauth</code> operand bundle.</strong></p>
<p>The ptrauth-calls attribute only describes calls emitted by the backend, as part of target-specific lowering (e.g., runtime calls for TLS accesses).</p>



<a name="204462393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204462393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204462393">(Jul 20 2020 at 19:05)</a>:</h4>
<p><code>call i64 @llvm.ptrauth.auth.i64</code> is a call to a function with <code>ptrauth</code> in its name.</p>



<a name="204462436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204462436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204462436">(Jul 20 2020 at 19:05)</a>:</h4>
<p><code>call void %fp() [ "ptrauth"(i32 &lt;key&gt;, i64 &lt;data&gt;) ]</code></p>



<a name="204462600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204462600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204462600">(Jul 20 2020 at 19:06)</a>:</h4>
<p>also, <code>%fp_auth = call i64 @llvm.ptrauth.auth.i64(i64 %fp_i, i32 &lt;key&gt;, i64 &lt;data&gt;)</code><br>
The original function <code>%fp_i</code> is still in thre.</p>



<a name="204462621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204462621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204462621">(Jul 20 2020 at 19:06)</a>:</h4>
<p>It's an LLVM intrinsic, I think.</p>



<a name="204462678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204462678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204462678">(Jul 20 2020 at 19:06)</a>:</h4>
<p>'<code>llvm.ptrauth.auth</code>'<br>
Syntax:</p>
<div class="codehilite"><pre><span></span><code>declare i64 @llvm.ptrauth.auth.i64(i64 &lt;value&gt;, i32 &lt;key&gt;, i64 &lt;extra data&gt;)
</code></pre></div>


<p>Overview:</p>
<p>The '<code>llvm.ptrauth.auth</code>' intrinsic authenticates a signed pointer.<br>
Arguments:</p>
<p>The <code>value</code> argument is the signed pointer value to be authenticated. The <code>key</code> argument is the identifier of the key that was used to generate the signed value. The <code>extra data</code> argument is the additional diversity data to be used as a discriminator.<br>
Semantics:</p>
<p>The 'llvm<code>.ptrauth.auth</code>' intrinsic implements the <code>auth</code>_ operation. It returns a raw, unauthenticated value. If <code>value</code> does not have a correct signature for <code>key</code> and <code>extra data</code>, the returned value is an invalid, poison pointer.</p>



<a name="204463106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204463106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204463106">(Jul 20 2020 at 19:10)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> so you're half right, it's a call to an llvm intristic.</p>



<a name="204463324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204463324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204463324">(Jul 20 2020 at 19:12)</a>:</h4>
<p>intrinsics are functions from the POV of the LLVM IR. All I mean is that <em>instructions</em> won't appear in the IR.</p>
<p>However, it doesn't appear that my points are helping you, so I'll stop responding about that to avoid creating more work.</p>



<a name="204463349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204463349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204463349">(Jul 20 2020 at 19:12)</a>:</h4>
<p>I'm sorry.</p>



<a name="204463390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204463390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204463390">(Jul 20 2020 at 19:12)</a>:</h4>
<p>I'm just trying to figure out how to figure out to get the rustc codegen to emit these intristics/functions.</p>



<a name="204463497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204463497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204463497">(Jul 20 2020 at 19:13)</a>:</h4>
<p>And i'm not sure how to do that.</p>



<a name="204463604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204463604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204463604">(Jul 20 2020 at 19:14)</a>:</h4>
<p>Certainly. You "just" have to figure out what <code>[ "ptrauth"(i32 &lt;key&gt;, i64 &lt;data&gt;) ]</code> maps to in the LLVM API, then where that part of the API is used in rustc, then how to add it.</p>



<a name="204463671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204463671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204463671">(Jul 20 2020 at 19:15)</a>:</h4>
<p>Sure. I'm guessing looking in Apple's Clang would be a good place to start?</p>



<a name="204464198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204464198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204464198">(Jul 20 2020 at 19:19)</a>:</h4>
<p>Doesn't seem like a bad idea! I'd also do some wild grepping for <code>ptrauth</code> in the LLVM source code to try and find things.</p>



<a name="204464297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204464297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204464297">(Jul 20 2020 at 19:20)</a>:</h4>
<p>I guess you also have the hard work of figuring out where to get the key and data from. Based on my 30 seconds of reading, the key might even be provided by the kernel itself.</p>



<a name="204464323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204464323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204464323">(Jul 20 2020 at 19:20)</a>:</h4>
<p>the key is a constant, 1/2/3/4 just refer to different keys</p>



<a name="204464349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204464349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204464349">(Jul 20 2020 at 19:20)</a>:</h4>
<p>altho yeah i think it's kernel provided</p>



<a name="204464365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204464365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204464365">(Jul 20 2020 at 19:21)</a>:</h4>
<p>Ah, and the 5th unused key would be <code>5</code> presumably?</p>



<a name="204464401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204464401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204464401">(Jul 20 2020 at 19:21)</a>:</h4>
<p>ye</p>



<a name="204465540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204465540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204465540">(Jul 20 2020 at 19:30)</a>:</h4>
<p>Potentially relevant clang code:</p>
<div class="codehilite"><pre><span></span><code><span class="n">EmitPointerAuthOperandBundle</span><span class="p">(</span><span class="n">ConcreteCallee</span><span class="p">.</span><span class="n">getPointerAuthInfo</span><span class="p">(),</span> <span class="n">BundleList</span><span class="p">);</span>
</code></pre></div>


<p>in <code>src/llvm-project/clang/lib/CodeGen/CGCall.cpp</code></p>



<a name="204465650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204465650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204465650">(Jul 20 2020 at 19:31)</a>:</h4>
<p>Relevant:</p>
<div class="codehilite"><pre><span></span><code><span class="kt">void</span> <span class="n">CodeGenFunction</span><span class="o">::</span><span class="n">EmitPointerAuthOperandBundle</span><span class="p">(</span>
                          <span class="k">const</span> <span class="n">CGPointerAuthInfo</span> <span class="o">&amp;</span><span class="n">pointerAuth</span><span class="p">,</span>
                          <span class="n">SmallVectorImpl</span><span class="o">&lt;</span><span class="n">llvm</span><span class="o">::</span><span class="n">OperandBundleDef</span><span class="o">&gt;</span> <span class="o">&amp;</span><span class="n">bundles</span><span class="p">);</span>

<span class="c1">/// Information necessary for pointer authentication.</span>
<span class="k">class</span> <span class="nc">CGPointerAuthInfo</span> <span class="p">{</span>
  <span class="kt">unsigned</span> <span class="nl">Signed</span> <span class="p">:</span> <span class="mi">1</span><span class="p">;</span>
  <span class="kt">unsigned</span> <span class="nl">Key</span> <span class="p">:</span> <span class="mi">31</span><span class="p">;</span>
  <span class="n">llvm</span><span class="o">::</span><span class="n">Value</span> <span class="o">*</span><span class="n">Discriminator</span><span class="p">;</span>

<span class="k">public</span><span class="o">:</span>
  <span class="n">CGPointerAuthInfo</span><span class="p">()</span> <span class="p">{</span> <span class="n">Signed</span> <span class="o">=</span> <span class="nb">false</span><span class="p">;</span> <span class="p">}</span>
  <span class="n">CGPointerAuthInfo</span><span class="p">(</span><span class="kt">unsigned</span> <span class="n">key</span><span class="p">,</span> <span class="n">llvm</span><span class="o">::</span><span class="n">Value</span> <span class="o">*</span><span class="n">discriminator</span><span class="p">)</span>
      <span class="o">:</span> <span class="n">Discriminator</span><span class="p">(</span><span class="n">discriminator</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">assert</span><span class="p">(</span><span class="o">!</span><span class="n">discriminator</span> <span class="o">||</span> <span class="n">discriminator</span><span class="o">-&gt;</span><span class="n">getType</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">isIntegerTy</span><span class="p">()</span> <span class="o">||</span>
           <span class="n">discriminator</span><span class="o">-&gt;</span><span class="n">getType</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">isPointerTy</span><span class="p">());</span>
    <span class="n">Signed</span> <span class="o">=</span> <span class="nb">true</span><span class="p">;</span>
    <span class="n">Key</span> <span class="o">=</span> <span class="n">key</span><span class="p">;</span>
  <span class="p">}</span>

  <span class="k">explicit</span> <span class="k">operator</span> <span class="kt">bool</span><span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">isSigned</span><span class="p">();</span> <span class="p">}</span>

  <span class="kt">bool</span> <span class="n">isSigned</span><span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">Signed</span><span class="p">;</span> <span class="p">}</span>

  <span class="kt">unsigned</span> <span class="n">getKey</span><span class="p">()</span> <span class="k">const</span> <span class="p">{</span>
    <span class="n">assert</span><span class="p">(</span><span class="n">isSigned</span><span class="p">());</span>
    <span class="k">return</span> <span class="n">Key</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="n">llvm</span><span class="o">::</span><span class="n">Value</span> <span class="o">*</span><span class="n">getDiscriminator</span><span class="p">()</span> <span class="k">const</span> <span class="p">{</span>
    <span class="n">assert</span><span class="p">(</span><span class="n">isSigned</span><span class="p">());</span>
    <span class="k">return</span> <span class="n">Discriminator</span><span class="p">;</span>
  <span class="p">}</span>
<span class="p">};</span>
</code></pre></div>



<a name="204466166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204466166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204466166">(Jul 20 2020 at 19:36)</a>:</h4>
<p>i'mm to tired due much about htis rn</p>



<a name="204474615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204474615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204474615">(Jul 20 2020 at 20:52)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> is this helpful? from Swift's code: </p>
<div class="codehilite"><pre><span></span><code><span class="n">llvm</span><span class="o">::</span><span class="n">Value</span> <span class="o">*</span><span class="n">irgen</span><span class="o">::</span><span class="n">emitPointerAuthAuth</span><span class="p">(</span><span class="n">IRGenFunction</span> <span class="o">&amp;</span><span class="n">IGF</span><span class="p">,</span> <span class="n">llvm</span><span class="o">::</span><span class="n">Value</span> <span class="o">*</span><span class="n">fnPtr</span><span class="p">,</span>
                                        <span class="k">const</span> <span class="n">PointerAuthInfo</span> <span class="o">&amp;</span><span class="n">oldAuthInfo</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">auto</span> <span class="n">origTy</span> <span class="o">=</span> <span class="n">fnPtr</span><span class="o">-&gt;</span><span class="n">getType</span><span class="p">();</span>
  <span class="n">fnPtr</span> <span class="o">=</span> <span class="n">IGF</span><span class="p">.</span><span class="n">Builder</span><span class="p">.</span><span class="n">CreatePtrToInt</span><span class="p">(</span><span class="n">fnPtr</span><span class="p">,</span> <span class="n">IGF</span><span class="p">.</span><span class="n">IGM</span><span class="p">.</span><span class="n">IntPtrTy</span><span class="p">);</span>

  <span class="k">auto</span> <span class="n">oldPair</span> <span class="o">=</span> <span class="n">getPointerAuthPair</span><span class="p">(</span><span class="n">IGF</span><span class="p">,</span> <span class="n">oldAuthInfo</span><span class="p">);</span>

  <span class="k">auto</span> <span class="n">intrinsic</span> <span class="o">=</span>
    <span class="n">llvm</span><span class="o">::</span><span class="n">Intrinsic</span><span class="o">::</span><span class="n">getDeclaration</span><span class="p">(</span><span class="o">&amp;</span><span class="n">IGF</span><span class="p">.</span><span class="n">IGM</span><span class="p">.</span><span class="n">Module</span><span class="p">,</span>
                                    <span class="n">llvm</span><span class="o">::</span><span class="n">Intrinsic</span><span class="o">::</span><span class="n">ptrauth_auth</span><span class="p">,</span>
                                    <span class="p">{</span> <span class="n">IGF</span><span class="p">.</span><span class="n">IGM</span><span class="p">.</span><span class="n">IntPtrTy</span> <span class="p">});</span>
  <span class="n">llvm</span><span class="o">::</span><span class="n">Value</span> <span class="o">*</span><span class="n">args</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span>
    <span class="n">fnPtr</span><span class="p">,</span> <span class="n">oldPair</span><span class="p">.</span><span class="n">first</span><span class="p">,</span> <span class="n">oldPair</span><span class="p">.</span><span class="n">second</span>
  <span class="p">};</span>
  <span class="n">fnPtr</span> <span class="o">=</span> <span class="n">IGF</span><span class="p">.</span><span class="n">Builder</span><span class="p">.</span><span class="n">CreateCall</span><span class="p">(</span><span class="n">intrinsic</span><span class="p">,</span> <span class="n">args</span><span class="p">);</span>
  <span class="k">return</span> <span class="n">IGF</span><span class="p">.</span><span class="n">Builder</span><span class="p">.</span><span class="n">CreateIntToPtr</span><span class="p">(</span><span class="n">fnPtr</span><span class="p">,</span> <span class="n">origTy</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div>



<a name="204474667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204474667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204474667">(Jul 20 2020 at 20:53)</a>:</h4>
<p>or</p>
<div class="codehilite"><pre><span></span><code><span class="n">llvm</span><span class="o">::</span><span class="n">CallInst</span> <span class="o">*</span><span class="n">IRBuilder</span><span class="o">::</span><span class="n">CreateCall</span><span class="p">(</span><span class="k">const</span> <span class="n">FunctionPointer</span> <span class="o">&amp;</span><span class="n">fn</span><span class="p">,</span>
                                      <span class="n">ArrayRef</span><span class="o">&lt;</span><span class="n">llvm</span><span class="o">::</span><span class="n">Value</span><span class="o">*&gt;</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span>
  <span class="n">SmallVector</span><span class="o">&lt;</span><span class="n">llvm</span><span class="o">::</span><span class="n">OperandBundleDef</span><span class="p">,</span> <span class="mi">1</span><span class="o">&gt;</span> <span class="n">bundles</span><span class="p">;</span>

  <span class="c1">// Add a pointer-auth bundle if necessary.</span>
  <span class="k">if</span> <span class="p">(</span><span class="k">const</span> <span class="k">auto</span> <span class="o">&amp;</span><span class="n">authInfo</span> <span class="o">=</span> <span class="n">fn</span><span class="p">.</span><span class="n">getAuthInfo</span><span class="p">())</span> <span class="p">{</span>
    <span class="k">auto</span> <span class="n">key</span> <span class="o">=</span> <span class="n">getInt32</span><span class="p">(</span><span class="n">authInfo</span><span class="p">.</span><span class="n">getKey</span><span class="p">());</span>
    <span class="k">auto</span> <span class="n">discriminator</span> <span class="o">=</span> <span class="n">authInfo</span><span class="p">.</span><span class="n">getDiscriminator</span><span class="p">();</span>
    <span class="n">llvm</span><span class="o">::</span><span class="n">Value</span> <span class="o">*</span><span class="n">bundleArgs</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="n">key</span><span class="p">,</span> <span class="n">discriminator</span> <span class="p">};</span>
    <span class="n">bundles</span><span class="p">.</span><span class="n">emplace_back</span><span class="p">(</span><span class="s">&quot;ptrauth&quot;</span><span class="p">,</span> <span class="n">bundleArgs</span><span class="p">);</span>
  <span class="p">}</span>

  <span class="n">assert</span><span class="p">(</span><span class="o">!</span><span class="n">isTrapIntrinsic</span><span class="p">(</span><span class="n">fn</span><span class="p">.</span><span class="n">getPointer</span><span class="p">())</span> <span class="o">&amp;&amp;</span> <span class="s">&quot;Use CreateNonMergeableTrap&quot;</span><span class="p">);</span>
  <span class="n">llvm</span><span class="o">::</span><span class="n">CallInst</span> <span class="o">*</span><span class="n">call</span> <span class="o">=</span> <span class="n">IRBuilderBase</span><span class="o">::</span><span class="n">CreateCall</span><span class="p">(</span>
      <span class="n">cast</span><span class="o">&lt;</span><span class="n">llvm</span><span class="o">::</span><span class="n">FunctionType</span><span class="o">&gt;</span><span class="p">(</span>
          <span class="n">fn</span><span class="p">.</span><span class="n">getPointer</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">getType</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">getPointerElementType</span><span class="p">()),</span>
      <span class="n">fn</span><span class="p">.</span><span class="n">getPointer</span><span class="p">(),</span> <span class="n">args</span><span class="p">,</span> <span class="n">bundles</span><span class="p">);</span>
  <span class="n">call</span><span class="o">-&gt;</span><span class="n">setAttributes</span><span class="p">(</span><span class="n">fn</span><span class="p">.</span><span class="n">getAttributes</span><span class="p">());</span>
  <span class="n">call</span><span class="o">-&gt;</span><span class="n">setCallingConv</span><span class="p">(</span><span class="n">fn</span><span class="p">.</span><span class="n">getCallingConv</span><span class="p">());</span>
  <span class="k">return</span> <span class="n">call</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>



<a name="204475006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204475006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204475006">(Jul 20 2020 at 20:57)</a>:</h4>
<p>I don't actually know. looks like you need to add a "bundle" with the ptrauth stuff, then attach it with <code>CreateCall</code>. You could look for similar code in rustc that calls something like <code>CreateCall</code> and try to pass in similar arguments.</p>



<a name="204475054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204475054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204475054">(Jul 20 2020 at 20:57)</a>:</h4>
<p>yeah, i've found it</p>



<a name="204477581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204477581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204477581">(Jul 20 2020 at 21:19)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">extern</span> <span class="s">&quot;C&quot;</span> <span class="n">LLVMValueRef</span> <span class="n">LLVMRustBuildCall</span><span class="p">(</span><span class="n">LLVMBuilderRef</span> <span class="n">B</span><span class="p">,</span> <span class="n">LLVMValueRef</span> <span class="n">Fn</span><span class="p">,</span>
                                          <span class="n">LLVMValueRef</span> <span class="o">*</span><span class="n">Args</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">NumArgs</span><span class="p">,</span>
                                          <span class="n">OperandBundleDef</span> <span class="o">*</span><span class="n">Bundle</span><span class="p">,</span> <span class="kt">bool</span> <span class="n">ptrauth</span><span class="p">)</span> <span class="p">{</span>
  <span class="n">Value</span> <span class="o">*</span><span class="n">Callee</span> <span class="o">=</span> <span class="n">unwrap</span><span class="p">(</span><span class="n">Fn</span><span class="p">);</span>
  <span class="n">FunctionType</span> <span class="o">*</span><span class="n">FTy</span> <span class="o">=</span> <span class="n">cast</span><span class="o">&lt;</span><span class="n">FunctionType</span><span class="o">&gt;</span><span class="p">(</span><span class="n">Callee</span><span class="o">-&gt;</span><span class="n">getType</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">getPointerElementType</span><span class="p">());</span>
  <span class="kt">unsigned</span> <span class="n">Len</span> <span class="o">=</span> <span class="n">Bundle</span> <span class="o">?</span> <span class="mi">1</span> <span class="o">:</span> <span class="mi">0</span><span class="p">;</span>
  <span class="n">ArrayRef</span><span class="o">&lt;</span><span class="n">OperandBundleDef</span><span class="o">&gt;</span> <span class="n">Bundles</span> <span class="o">=</span> <span class="n">makeArrayRef</span><span class="p">(</span><span class="n">Bundle</span><span class="p">,</span> <span class="n">Len</span><span class="p">);</span>
  <span class="k">if</span> <span class="p">(</span><span class="n">ptrauth</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">llvm</span><span class="o">::</span><span class="n">Value</span> <span class="o">*</span><span class="n">bundleArgs</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span> <span class="p">};</span>
    <span class="n">bundles</span><span class="p">.</span><span class="n">emplace_back</span><span class="p">(</span><span class="s">&quot;ptrauth&quot;</span><span class="p">,</span> <span class="n">bundleArgs</span><span class="p">);</span>
  <span class="p">}</span>
  <span class="k">return</span> <span class="n">wrap</span><span class="p">(</span><span class="n">unwrap</span><span class="p">(</span><span class="n">B</span><span class="p">)</span><span class="o">-&gt;</span><span class="n">CreateCall</span><span class="p">(</span>
      <span class="n">FTy</span><span class="p">,</span> <span class="n">Callee</span><span class="p">,</span> <span class="n">makeArrayRef</span><span class="p">(</span><span class="n">unwrap</span><span class="p">(</span><span class="n">Args</span><span class="p">),</span> <span class="n">NumArgs</span><span class="p">),</span> <span class="n">Bundles</span><span class="p">));</span>
<span class="p">}</span>
</code></pre></div>



<a name="204477587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204477587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204477587">(Jul 20 2020 at 21:19)</a>:</h4>
<p>this might work?</p>



<a name="204479168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204479168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204479168">(Jul 20 2020 at 21:34)</a>:</h4>
<p>well that didn't work, this compiled tho: </p>
<div class="codehilite"><pre><span></span><code><span class="k">extern</span> <span class="s">&quot;C&quot;</span> <span class="n">LLVMValueRef</span> <span class="n">LLVMRustBuildCall</span><span class="p">(</span><span class="n">LLVMBuilderRef</span> <span class="n">B</span><span class="p">,</span> <span class="n">LLVMValueRef</span> <span class="n">Fn</span><span class="p">,</span>
                                          <span class="n">LLVMValueRef</span> <span class="o">*</span><span class="n">Args</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">NumArgs</span><span class="p">,</span>
                                          <span class="n">OperandBundleDef</span> <span class="o">*</span><span class="n">Bundle</span><span class="p">,</span> <span class="kt">bool</span> <span class="n">ptrauth</span><span class="p">)</span> <span class="p">{</span>
  <span class="n">Value</span> <span class="o">*</span><span class="n">Callee</span> <span class="o">=</span> <span class="n">unwrap</span><span class="p">(</span><span class="n">Fn</span><span class="p">);</span>
  <span class="n">FunctionType</span> <span class="o">*</span><span class="n">FTy</span> <span class="o">=</span> <span class="n">cast</span><span class="o">&lt;</span><span class="n">FunctionType</span><span class="o">&gt;</span><span class="p">(</span><span class="n">Callee</span><span class="o">-&gt;</span><span class="n">getType</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">getPointerElementType</span><span class="p">());</span>
  <span class="kt">unsigned</span> <span class="n">Len</span> <span class="o">=</span> <span class="n">Bundle</span> <span class="o">?</span> <span class="mi">1</span> <span class="o">:</span> <span class="mi">0</span><span class="p">;</span>
  <span class="n">ArrayRef</span><span class="o">&lt;</span><span class="n">OperandBundleDef</span><span class="o">&gt;</span> <span class="n">Bundles</span> <span class="o">=</span> <span class="n">makeArrayRef</span><span class="p">(</span><span class="n">Bundle</span><span class="p">,</span> <span class="n">Len</span><span class="p">);</span>
  <span class="k">if</span> <span class="p">(</span><span class="n">ptrauth</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">llvm</span><span class="o">::</span><span class="n">Value</span> <span class="o">*</span><span class="n">bundleArgs</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span> <span class="p">};</span>
    <span class="n">OperandBundleDef</span> <span class="n">PtrauthPlusBundles</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="o">*</span><span class="n">Bundle</span><span class="p">,</span> <span class="n">OperandBundleDef</span><span class="p">(</span><span class="s">&quot;ptrauth&quot;</span><span class="p">,</span> <span class="n">bundleArgs</span><span class="p">)</span> <span class="p">};</span>
    <span class="k">return</span> <span class="nf">wrap</span><span class="p">(</span><span class="n">unwrap</span><span class="p">(</span><span class="n">B</span><span class="p">)</span><span class="o">-&gt;</span><span class="n">CreateCall</span><span class="p">(</span>
      <span class="n">FTy</span><span class="p">,</span> <span class="n">Callee</span><span class="p">,</span> <span class="n">makeArrayRef</span><span class="p">(</span><span class="n">unwrap</span><span class="p">(</span><span class="n">Args</span><span class="p">),</span> <span class="n">NumArgs</span><span class="p">),</span> <span class="n">PtrauthPlusBundles</span><span class="p">));</span>
  <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
    <span class="k">return</span> <span class="n">wrap</span><span class="p">(</span><span class="n">unwrap</span><span class="p">(</span><span class="n">B</span><span class="p">)</span><span class="o">-&gt;</span><span class="n">CreateCall</span><span class="p">(</span>
        <span class="n">FTy</span><span class="p">,</span> <span class="n">Callee</span><span class="p">,</span> <span class="n">makeArrayRef</span><span class="p">(</span><span class="n">unwrap</span><span class="p">(</span><span class="n">Args</span><span class="p">),</span> <span class="n">NumArgs</span><span class="p">),</span> <span class="n">Bundles</span><span class="p">));</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div>



<a name="204479944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204479944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204479944">(Jul 20 2020 at 21:43)</a>:</h4>
<div class="codehilite"><pre><span></span><code>Building stage2 std artifacts (x86_64-apple-darwin -&gt; arm64e-apple-ios)
   Compiling core v0.0.0 (/Users/aleister/Code/rust/src/libcore)
   Compiling libc v0.2.72
   Compiling compiler_builtins v0.1.32
   Compiling unwind v0.0.0 (/Users/aleister/Code/rust/src/libunwind)
   Compiling backtrace-sys v0.1.37
   Compiling hashbrown v0.6.3
   Compiling std v0.0.0 (/Users/aleister/Code/rust/src/libstd)
   Compiling rustc-std-workspace-core v1.99.0 (/Users/aleister/Code/rust/src/tools/rustc-std-workspace-core)
error: could not compile `core`.

Caused by:
  process didn&#39;t exit successfully: `/Users/aleister/Code/rust/build/bootstrap/debug/rustc --crate-name core --edition=2018 src/libcore/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -Cembed-bitcode=no -C debuginfo=0 -C metadata=7addea7693d625b6 -C extra-filename=-7addea7693d625b6 --out-dir /Users/aleister/Code/rust/build/x86_64-apple-darwin/stage2-std/arm64e-apple-ios/release/deps --target arm64e-apple-ios -C linker=cc -C incremental=/Users/aleister/Code/rust/build/x86_64-apple-darwin/stage2-std/arm64e-apple-ios/release/incremental -L dependency=/Users/aleister/Code/rust/build/x86_64-apple-darwin/stage2-std/arm64e-apple-ios/release/deps -L dependency=/Users/aleister/Code/rust/build/x86_64-apple-darwin/stage2-std/release/deps -Zmacro-backtrace -Zosx-rpath-install-name &#39;-Clink-args=-Wl,-rpath,@loader_path/../lib&#39; -Cprefer-dynamic -Cllvm-args=-import-instr-limit=10 -Cembed-bitcode=yes -Zbinary-dep-depinfo` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: build failed
command did not execute successfully: &quot;/Users/aleister/Code/rust/build/x86_64-apple-darwin/stage0/bin/cargo&quot; &quot;build&quot; &quot;--target&quot; &quot;arm64e-apple-ios&quot; &quot;-Zbinary-dep-depinfo&quot; &quot;-j&quot; &quot;6&quot; &quot;--release&quot; &quot;--features&quot; &quot;panic-unwind backtrace compiler-builtins-c&quot; &quot;--manifest-path&quot; &quot;/Users/aleister/Code/rust/src/libtest/Cargo.toml&quot; &quot;--message-format&quot; &quot;json-render-diagnostics&quot;
expected success, got: exit code: 101
failed to run: /Users/aleister/Code/rust/build/bootstrap/debug/bootstrap build
Build completed unsuccessfully in 0:09:54
</code></pre></div>



<a name="204498575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204498575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204498575">(Jul 20 2020 at 23:55)</a>:</h4>
<p>my brain is too fried to continue</p>



<a name="204498597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204498597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204498597">(Jul 20 2020 at 23:55)</a>:</h4>
<p>help from anyone who has knowledge in librust_codegen_llvm would be appreciated</p>



<a name="204504913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204504913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204504913">(Jul 21 2020 at 01:42)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> would you be able to help? you seem to know a bit about the internals of this.<br>
I'm trying to figure out stuff regarding applying ptrauth bundles to calls/invokes.<br>
Like tracking Key/Discriminator for functions / calls?<br>
<a href="/user_uploads/4715/38bhlPK5gqaMEzr0LUxORZNj/chrome_Vc0K1FgBNZ.png">chrome_Vc0K1FgBNZ.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/38bhlPK5gqaMEzr0LUxORZNj/chrome_Vc0K1FgBNZ.png" title="chrome_Vc0K1FgBNZ.png"><img src="/user_uploads/4715/38bhlPK5gqaMEzr0LUxORZNj/chrome_Vc0K1FgBNZ.png"></a></div>



<a name="204505571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204505571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204505571">(Jul 21 2020 at 01:56)</a>:</h4>
<p><a href="/user_uploads/4715/cNNKe3ECVUDmA2vZ7_DgBtQS/IMG_1201.PNG">IMG_1201.PNG</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/cNNKe3ECVUDmA2vZ7_DgBtQS/IMG_1201.PNG" title="IMG_1201.PNG"><img src="/user_uploads/4715/cNNKe3ECVUDmA2vZ7_DgBtQS/IMG_1201.PNG"></a></div>



<a name="204506265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506265">(Jul 21 2020 at 02:10)</a>:</h4>
<p>relevant PR to look at is the one that introduces addrspace handling for AVR</p>



<a name="204506266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506266">(Jul 21 2020 at 02:10)</a>:</h4>
<p>it should be open somewhere, probably assigned to me</p>



<a name="204506770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506770">(Jul 21 2020 at 02:21)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> wait, which part of it?</p>



<a name="204506826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506826">(Jul 21 2020 at 02:22)</a>:</h4>
<p>the part that remembers the function pointers use a different address space than data.</p>



<a name="204506841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506841">(Jul 21 2020 at 02:22)</a>:</h4>
<p>ooh yeah</p>



<a name="204506845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506845">(Jul 21 2020 at 02:22)</a>:</h4>
<p>and i'd implement something for the origin of a function pointer?</p>



<a name="204506854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506854">(Jul 21 2020 at 02:23)</a>:</h4>
<p>wait</p>



<a name="204506858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506858">(Jul 21 2020 at 02:23)</a>:</h4>
<p>how does that help with determining if a call/invoke is direct or indirect</p>



<a name="204506860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506860">(Jul 21 2020 at 02:23)</a>:</h4>
<p>so you would ptrsign when the pointers are created or something and use the signed way to call said pointers</p>



<a name="204506861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506861">(Jul 21 2020 at 02:23)</a>:</h4>
<p>sorry if i'm being dumb here</p>



<a name="204506864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506864">(Jul 21 2020 at 02:23)</a>:</h4>
<p>it all can be done based on types.</p>



<a name="204506868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506868">(Jul 21 2020 at 02:23)</a>:</h4>
<p>oh yeah</p>



<a name="204506914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506914">(Jul 21 2020 at 02:24)</a>:</h4>
<p>in particular function pointers don’t come from vacuum, you will always begin with some sort of a symbol (declaration or definition)</p>



<a name="204506929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506929">(Jul 21 2020 at 02:24)</a>:</h4>
<p>I guess the exception would be JIT stuff.</p>



<a name="204506947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506947">(Jul 21 2020 at 02:25)</a>:</h4>
<p>so hm, here's where I'd stick a key/discriminator on a function ptr?</p>



<a name="204506951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506951">(Jul 21 2020 at 02:25)</a>:</h4>
<p>and maybe, just maybe dlopen stuff.</p>



<a name="204506953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506953">(Jul 21 2020 at 02:25)</a>:</h4>
<p>in librustc_middle</p>



<a name="204506967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506967">(Jul 21 2020 at 02:25)</a>:</h4>
<p><span class="user-mention" data-user-id="312033">@aspen</span> is the user expected to carry this about by themselves?</p>



<a name="204506989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204506989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204506989">(Jul 21 2020 at 02:26)</a>:</h4>
<p>no</p>



<a name="204507012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507012">(Jul 21 2020 at 02:26)</a>:</h4>
<p>if its supposed to be all automatic, the whole thing probably needs to be dealt with in the backend</p>



<a name="204507013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507013">(Jul 21 2020 at 02:26)</a>:</h4>
<p>what i meant was generatign the key/discriminator for a fn in librustc_middle</p>



<a name="204507036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507036">(Jul 21 2020 at 02:26)</a>:</h4>
<p>oh, not sure why you’d need it to be in <code>librustc_middle</code> at all.</p>



<a name="204507039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507039">(Jul 21 2020 at 02:27)</a>:</h4>
<p>can the key/discriminator be a hash of some sort?</p>



<a name="204507042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507042">(Jul 21 2020 at 02:27)</a>:</h4>
<p>yes</p>



<a name="204507046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507046">(Jul 21 2020 at 02:27)</a>:</h4>
<p>key is u32, discriminator is u64</p>



<a name="204507052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507052">(Jul 21 2020 at 02:27)</a>:</h4>
<p>actually the key is just 0/1/2/3</p>



<a name="204507058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507058">(Jul 21 2020 at 02:27)</a>:</h4>
<p>discriminator can be 0 or it can be a hash. in swift, it's a hash of the function signature and stuff.</p>



<a name="204507099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507099">(Jul 21 2020 at 02:28)</a>:</h4>
<p>yeah, that’s what I’d do then, just StableHash the function pointer type or something</p>



<a name="204507110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507110">(Jul 21 2020 at 02:28)</a>:</h4>
<p>how useful this scheme is ultimately will depend on what goes in to the hash</p>



<a name="204507112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507112">(Jul 21 2020 at 02:28)</a>:</h4>
<p>does rustc track whether calls are indirect or direct calls?</p>



<a name="204507120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507120">(Jul 21 2020 at 02:29)</a>:</h4>
<p>yeah, it depends on the type.</p>



<a name="204507124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507124">(Jul 21 2020 at 02:29)</a>:</h4>
<p>because "Direct calls to statically known functions" don't need any sort of auth</p>



<a name="204507133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507133">(Jul 21 2020 at 02:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/How.20to.20get.20rustc.20to.20generate.20LLVM.20IR.20differently.3F/near/204507120">said</a>:</p>
<blockquote>
<p>yeah, it depends on the type.</p>
</blockquote>
<p>what file would this be in?</p>



<a name="204507136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507136">(Jul 21 2020 at 02:29)</a>:</h4>
<p>Since this is an LLVM thing and I'm just sitting in librustc_codegen_llvm</p>



<a name="204507193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507193">(Jul 21 2020 at 02:30)</a>:</h4>
<p>Look for <code>ty::FnPtr</code> and <code>ty::FnDef</code>. The rust types will be available in <code>librustc_codegen_llvm</code> for pretty much everything.</p>



<a name="204507222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507222">(Jul 21 2020 at 02:31)</a>:</h4>
<p>FnDef would be a direct, FnPtr would not be?</p>



<a name="204507225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507225">(Jul 21 2020 at 02:31)</a>:</h4>
<p>src/librustc_middle/ty/sty.rs has the variant definitions.</p>



<a name="204507228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507228">(Jul 21 2020 at 02:31)</a>:</h4>
<p>with the relevant documentation</p>



<a name="204507304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507304">(Jul 21 2020 at 02:32)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.TyKind.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.TyKind.html</a> may be useful</p>



<a name="204507308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507308">(Jul 21 2020 at 02:32)</a>:</h4>
<p>no, the FnDef is the type, FnPtr is the actual pointer</p>



<a name="204507309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507309">(Jul 21 2020 at 02:32)</a>:</h4>
<p>hm</p>



<a name="204507344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507344">(Jul 21 2020 at 02:34)</a>:</h4>
<p>calling a value of <code>FnDef</code> type is going to become a direct static call in LLVM IR</p>



<a name="204507374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507374">(Jul 21 2020 at 02:34)</a>:</h4>
<p>OOH, I see</p>



<a name="204507384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507384">(Jul 21 2020 at 02:34)</a>:</h4>
<p>calling a value of <code>FnPtr</code> type is going to become a function pointer call.</p>



<a name="204507395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507395">(Jul 21 2020 at 02:34)</a>:</h4>
<p>but hm, how do the ty::FnDef/FnPtr boil down to what's used in a LLVM IR call/invoke builder?</p>



<a name="204507412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507412">(Jul 21 2020 at 02:35)</a>:</h4>
<p>Sorry if I'm rather confused.</p>



<a name="204507495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507495">(Jul 21 2020 at 02:36)</a>:</h4>
<p>this is how a ptrauth bundle is made btw:</p>
<div class="codehilite"><pre><span></span><code><span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ptrauth_args</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="n">llvm</span>::<span class="n">ConstInt32</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">cx</span><span class="p">.</span><span class="n">llcx</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">),</span><span class="w"> </span><span class="n">llvm</span>::<span class="n">ConstInt64</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">cx</span><span class="p">.</span><span class="n">llcx</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">)];</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ptrauth_bundle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">OperandBundleDef</span>::<span class="n">new</span><span class="p">(</span><span class="s">&quot;ptrauth&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">ptrauth_args</span><span class="p">);</span><span class="w"></span>
</code></pre></div>



<a name="204507588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507588">(Jul 21 2020 at 02:38)</a>:</h4>
<p>because all the call()/invoke() seem to be in the agonistic backend</p>



<a name="204507592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507592">(Jul 21 2020 at 02:38)</a>:</h4>
<p>which ofc is unaware of ptrauth</p>



<a name="204507626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507626">(Jul 21 2020 at 02:39)</a>:</h4>
<p>You might want to look around <code>librustc_codegen_ssa</code>. Its closely related to the <code>_llvm</code> crate (and they work together)</p>



<a name="204507669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507669">(Jul 21 2020 at 02:40)</a>:</h4>
<p>ye, but ssa is _unaware_ of LLVM types last I checked?</p>



<a name="204507684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507684">(Jul 21 2020 at 02:40)</a>:</h4>
<p><code>librustc_codegen_ssa/mir/rvalue.rs</code> for instance has code that does the reification (i.e. conversion from fndef to fnptr)</p>



<a name="204507711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507711">(Jul 21 2020 at 02:41)</a>:</h4>
<p>so wait, what would I do with that?</p>



<a name="204507737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507737">(Jul 21 2020 at 02:42)</a>:</h4>
<p>yeah it is intended to be more generic than just llvm, so you might need to introduce some sort of a more generic infrastructure for ptrauth than exactly mapping directly to LLVM constructs.</p>



<a name="204507761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507761">(Jul 21 2020 at 02:42)</a>:</h4>
<p>that said… this whole split was halfway done and left there, so you will always see some intersection between the two crates.</p>



<a name="204507766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507766">(Jul 21 2020 at 02:42)</a>:</h4>
<p>tbh rn all I care about is passing down "is this a direct or indirect call" to LLVM</p>



<a name="204507767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507767">(Jul 21 2020 at 02:42)</a>:</h4>
<p>and I haven’t worked on backend since the time the split occurred.</p>



<a name="204507770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507770">(Jul 21 2020 at 02:42)</a>:</h4>
<p>you can just hack it in for the initial pass.</p>



<a name="204507778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507778">(Jul 21 2020 at 02:43)</a>:</h4>
<p>ye I can't just slap the ptrauth bundle on everything tho</p>



<a name="204507782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507782">(Jul 21 2020 at 02:43)</a>:</h4>
<p>this isn't being PR'd due to the fact it's using an entirely different LLVM</p>



<a name="204507788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507788">(Jul 21 2020 at 02:43)</a>:</h4>
<p>i just can't find where I'd manage to pass down "is this indirect or direct" to call()/invoke()</p>



<a name="204507858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507858">(Jul 21 2020 at 02:45)</a>:</h4>
<p>the highest I can find is <code>do_call</code></p>



<a name="204507863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507863">(Jul 21 2020 at 02:45)</a>:</h4>
<p>and I don't think that's aware of ty::FnDef/ty::FnPtr</p>



<a name="204507915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507915">(Jul 21 2020 at 02:46)</a>:</h4>
<p>... hm, is FnAbi aware of it?</p>



<a name="204507938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507938">(Jul 21 2020 at 02:47)</a>:</h4>
<p>... don't think so. ugh.</p>



<a name="204507939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507939">(Jul 21 2020 at 02:47)</a>:</h4>
<p>codegen_call_terminator is what’s up the stack.</p>



<a name="204507942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507942">(Jul 21 2020 at 02:47)</a>:</h4>
<p>oh, the name put me off.</p>



<a name="204507996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204507996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204507996">(Jul 21 2020 at 02:49)</a>:</h4>
<p>ultimately it'll be up to you to figure out how to thread through the necessary information.</p>



<a name="204508001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204508001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204508001">(Jul 21 2020 at 02:49)</a>:</h4>
<p>at the very least I haven’t even looked at the backend code for many months now.</p>



<a name="204508005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204508005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204508005">(Jul 21 2020 at 02:49)</a>:</h4>
<p>... this is a big hack, sooo</p>
<div class="codehilite"><pre><span></span><code><span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">needs_ptrauth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">callee</span><span class="p">.</span><span class="n">layout</span><span class="p">.</span><span class="n">ty</span><span class="p">.</span><span class="n">kind</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">ty</span>::<span class="n">FnDef</span><span class="p">(</span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="n">ty</span>::<span class="n">FnPtr</span><span class="p">(</span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">};</span><span class="w"></span>
</code></pre></div>



<a name="204508779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204508779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204508779">(Jul 21 2020 at 03:13)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error[E0521]: borrowed data escapes outside of associated function
   --&gt; src/librustc_codegen_llvm/builder.rs:211:20
    |
194 |         &amp;mut self,
    |         --------- `self` declared here, outside of the associated function body
...
199 |         funclet: Option&lt;&amp;Funclet&lt;&#39;ll&gt;&gt;,
    |         ------- `funclet` is a reference that is only valid in the associated function body
...
211 |         let args = self.check_call(&quot;invoke&quot;, llfn, args);
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `funclet` escapes the associated function body here

error[E0515]: cannot return value referencing local variable `ptrauth_bundle`
   --&gt; src/librustc_codegen_llvm/builder.rs:222:13
    |
208 |               bundles.push(&amp;ptrauth_bundle);
    |                            --------------- `ptrauth_bundle` is borrowed here
...
222 | /             llvm::LLVMRustBuildInvoke(
223 | |                 self.llbuilder,
224 | |                 llfn,
225 | |                 args.as_ptr(),
...   |
231 | |                 UNNAMED,
232 | |             )
    | |_____________^ returns a value referencing data owned by the current function
</code></pre></div>



<a name="204508817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204508817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204508817">(Jul 21 2020 at 03:14)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="w">    </span><span class="k">fn</span> <span class="nf">invoke</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">llfn</span>: <span class="kp">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">Value</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">args</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="o">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">Value</span><span class="p">],</span><span class="w"></span>
<span class="w">        </span><span class="n">then</span>: <span class="kp">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">BasicBlock</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">catch</span>: <span class="kp">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">BasicBlock</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">funclet</span>: <span class="nb">Option</span><span class="o">&lt;&amp;</span><span class="n">Funclet</span><span class="o">&lt;</span><span class="na">&#39;ll</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">ptrauth</span>: <span class="kt">bool</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">Value</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">debug</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;invoke {:?} with args ({:?})&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">llfn</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">bundles</span>: <span class="nb">Vec</span><span class="o">&lt;&amp;</span><span class="n">OperandBundleDef</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vec</span><span class="o">!</span><span class="p">[];</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ptrauth_crap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="n">llvm</span>::<span class="n">ConstInt32</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">cx</span><span class="p">.</span><span class="n">llcx</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">),</span><span class="w"> </span><span class="n">llvm</span>::<span class="n">ConstInt64</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">cx</span><span class="p">.</span><span class="n">llcx</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">)];</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ptrauth_bundle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">OperandBundleDef</span>::<span class="n">new</span><span class="p">(</span><span class="s">&quot;ptrauth&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">ptrauth_crap</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="n">ptrauth</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">bundles</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="o">&amp;</span><span class="n">ptrauth_bundle</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">args</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">check_call</span><span class="p">(</span><span class="s">&quot;invoke&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">llfn</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">funclet_bundle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">funclet</span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">funclet</span><span class="o">|</span><span class="w"> </span><span class="n">funclet</span><span class="p">.</span><span class="n">bundle</span><span class="p">());</span><span class="w"></span>

<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">funclet_bundle</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">funclet_bundle</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">bundles</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">funclet_bundle</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">bundles</span>: <span class="nb">Vec</span><span class="o">&lt;</span><span class="n">_</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">bundles</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">b</span><span class="o">|</span><span class="w"> </span><span class="o">&amp;*</span><span class="n">b</span><span class="p">.</span><span class="n">raw</span><span class="p">).</span><span class="n">collect</span><span class="p">();</span><span class="w"></span>


<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">llvm</span>::<span class="n">LLVMRustBuildInvoke</span><span class="p">(</span><span class="w"></span>
<span class="w">                </span><span class="bp">self</span><span class="p">.</span><span class="n">llbuilder</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">llfn</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">args</span><span class="p">.</span><span class="n">as_ptr</span><span class="p">(),</span><span class="w"></span>
<span class="w">                </span><span class="n">args</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">c_uint</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">then</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">catch</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="nb">Some</span><span class="p">(</span><span class="o">&amp;</span><span class="n">bundles</span><span class="p">[</span><span class="o">..</span><span class="p">]),</span><span class="w"></span>
<span class="w">                </span><span class="n">bundles</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">c_uint</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">UNNAMED</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="204508823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204508823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204508823">(Jul 21 2020 at 03:14)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> i apologize if it's obvious but what am I doing wrong here?</p>



<a name="204508961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204508961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204508961">(Jul 21 2020 at 03:18)</a>:</h4>
<p>going to sleep so not going to respond before at least 8 hours later.</p>



<a name="204508968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204508968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204508968">(Jul 21 2020 at 03:18)</a>:</h4>
<p>alright, g'night</p>



<a name="204563653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204563653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204563653">(Jul 21 2020 at 15:37)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error[E0521]: borrowed data escapes outside of associated function
   --&gt; src/librustc_codegen_llvm/builder.rs:207:20
    |
194 |         &amp;mut self,
    |         --------- `self` declared here, outside of the associated function body
...
199 |         funclet: Option&lt;&amp;Funclet&lt;&#39;ll&gt;&gt;,
    |         ------- `funclet` is a reference that is only valid in the associated function body
...
207 |         let args = self.check_call(&quot;call&quot;, llfn, args);
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `funclet` escapes the associated function body here

error[E0515]: cannot return value referencing local variable `ptrauth_bundle`
   --&gt; src/librustc_codegen_llvm/builder.rs:216:13
    |
211 |               Some(&amp;ptrauth_bundle).as_ref().map(|b| &amp;*b.raw)
    |                    --------------- `ptrauth_bundle` is borrowed here
...
216 | /             llvm::LLVMRustBuildInvoke(
217 | |                 self.llbuilder,
218 | |                 llfn,
219 | |                 args.as_ptr(),
...   |
225 | |                 UNNAMED,
226 | |             )
    | |_____________^ returns a value referencing data owned by the current function
</code></pre></div>



<a name="204563675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204563675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204563675">(Jul 21 2020 at 15:37)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="w">    </span><span class="k">fn</span> <span class="nf">invoke</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">llfn</span>: <span class="kp">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">Value</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">args</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="o">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">Value</span><span class="p">],</span><span class="w"></span>
<span class="w">        </span><span class="n">then</span>: <span class="kp">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">BasicBlock</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">catch</span>: <span class="kp">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">BasicBlock</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">funclet</span>: <span class="nb">Option</span><span class="o">&lt;&amp;</span><span class="n">Funclet</span><span class="o">&lt;</span><span class="na">&#39;ll</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">ptrauth</span>: <span class="kt">bool</span>
    <span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="na">&#39;ll</span><span class="w"> </span><span class="n">Value</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">debug</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;invoke {:?} with args ({:?})&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">llfn</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">);</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ptrauth_args</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="n">llvm</span>::<span class="n">ConstInt32</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">cx</span><span class="p">.</span><span class="n">llcx</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">),</span><span class="w"> </span><span class="n">llvm</span>::<span class="n">ConstInt64</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">cx</span><span class="p">.</span><span class="n">llcx</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">)];</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ptrauth_bundle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">OperandBundleDef</span>::<span class="n">new</span><span class="p">(</span><span class="s">&quot;ptrauth&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">ptrauth_args</span><span class="p">);</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">args</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">check_call</span><span class="p">(</span><span class="s">&quot;call&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">llfn</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">bundle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">funclet</span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">funclet</span><span class="o">|</span><span class="w"> </span><span class="n">funclet</span><span class="p">.</span><span class="n">bundle</span><span class="p">());</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">bundle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">bundle</span><span class="p">.</span><span class="n">as_ref</span><span class="p">().</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">b</span><span class="o">|</span><span class="w"> </span><span class="o">&amp;*</span><span class="n">b</span><span class="p">.</span><span class="n">raw</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">pac_bundle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">ptrauth</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="nb">Some</span><span class="p">(</span><span class="o">&amp;</span><span class="n">ptrauth_bundle</span><span class="p">).</span><span class="n">as_ref</span><span class="p">().</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">b</span><span class="o">|</span><span class="w"> </span><span class="o">&amp;*</span><span class="n">b</span><span class="p">.</span><span class="n">raw</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="nb">None</span><span class="w"></span>
<span class="w">        </span><span class="p">};</span><span class="w"></span>
<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">llvm</span>::<span class="n">LLVMRustBuildInvoke</span><span class="p">(</span><span class="w"></span>
<span class="w">                </span><span class="bp">self</span><span class="p">.</span><span class="n">llbuilder</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">llfn</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">args</span><span class="p">.</span><span class="n">as_ptr</span><span class="p">(),</span><span class="w"></span>
<span class="w">                </span><span class="n">args</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">c_uint</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">then</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">catch</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">bundle</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">pac_bundle</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">UNNAMED</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="204563700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204563700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204563700">(Jul 21 2020 at 15:37)</a>:</h4>
<p>I am confused about how I got this to work earlier.</p>



<a name="204570609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204570609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204570609">(Jul 21 2020 at 16:32)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> idk what I'm doing wrong</p>
<div class="codehilite"><pre><span></span><code>   Compiling backtrace v0.3.50
LLVM ERROR: Cannot lower direct authenticated call to unauthenticated target
error: could not compile `backtrace`.
</code></pre></div>


<div class="codehilite"><pre><span></span><code><span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">use_pac</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">bx</span><span class="p">.</span><span class="n">tcx</span><span class="p">().</span><span class="n">sess</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">options</span><span class="p">.</span><span class="n">use_pac</span><span class="w"></span>
<span class="w">            </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">callee</span><span class="p">.</span><span class="n">layout</span><span class="p">.</span><span class="n">ty</span><span class="p">.</span><span class="n">kind</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="n">ty</span>::<span class="n">FnDef</span><span class="p">(</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">ty</span>::<span class="n">FnPtr</span><span class="p">(</span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="p">};</span><span class="w"></span>
</code></pre></div>



<a name="204570867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204570867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204570867">(Jul 21 2020 at 16:34)</a>:</h4>
<p><a href="user_uploads/4715/Ll1OLHcIjS1-CN3g8LC3JBbS/chrome_rUyHQJGQDf.png">chrome_rUyHQJGQDf.png</a></p>
<div class="message_inline_image"><a href="user_uploads/4715/Ll1OLHcIjS1-CN3g8LC3JBbS/chrome_rUyHQJGQDf.png" title="chrome_rUyHQJGQDf.png"><img src="user_uploads/4715/Ll1OLHcIjS1-CN3g8LC3JBbS/chrome_rUyHQJGQDf.png"></a></div>



<a name="204577962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204577962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204577962">(Jul 21 2020 at 17:34)</a>:</h4>
<p><span class="user-mention" data-user-id="312033">@aspen</span> did you actually authenticate the function pointers where they are reified (i.e. converted from FnDef to FnPtr)?</p>



<a name="204578019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204578019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204578019">(Jul 21 2020 at 17:34)</a>:</h4>
<p>I'm just using a 0 key/discriminator for now</p>



<a name="204578040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204578040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204578040">(Jul 21 2020 at 17:34)</a>:</h4>
<p>and I just pass the "use_pac" bool down to call/invoke</p>



<a name="204578344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204578344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204578344">(Jul 21 2020 at 17:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/How.20to.20get.20rustc.20to.20generate.20LLVM.20IR.20differently.3F/near/204577962">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="312033">aspen</span> did you actually authenticate the function pointers where they are reified (i.e. converted from FnDef to FnPtr)?</p>
</blockquote>
<p>wait I think I misunderstood this, do you mean signing or authing the pointers?</p>



<a name="204580003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580003">(Jul 21 2020 at 17:51)</a>:</h4>
<p>my use of terminology here might be fairly lax</p>



<a name="204580025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580025">(Jul 21 2020 at 17:51)</a>:</h4>
<p>i'm only adding the ptrauth bundle if it's a FnPtr</p>



<a name="204580027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580027">(Jul 21 2020 at 17:51)</a>:</h4>
<p>I meant whatever makes the sense for when you produce function pointers.</p>



<a name="204580101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580101">(Jul 21 2020 at 17:52)</a>:</h4>
<p>is it possible for a FnPtr to be a direct call?</p>



<a name="204580121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580121">(Jul 21 2020 at 17:52)</a>:</h4>
<p>yeah, but that portion of code that you linked is only affecting the calls.</p>



<a name="204580130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580130">(Jul 21 2020 at 17:52)</a>:</h4>
<p>pointers still need to come from somewhere.</p>



<a name="204580141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580141">(Jul 21 2020 at 17:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312033">aspen</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/How.20to.20get.20rustc.20to.20generate.20LLVM.20IR.20differently.3F/near/204580101">said</a>:</p>
<blockquote>
<p>is it possible for a FnPtr to be a direct call?</p>
</blockquote>
<p>not that I know of.</p>



<a name="204580165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580165">(Jul 21 2020 at 17:52)</a>:</h4>
<p>hm, since only FnPtrs are having the use_ptrauth bool passed down</p>



<a name="204580187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580187">(Jul 21 2020 at 17:53)</a>:</h4>
<p>i have this on both call and invoke</p>



<a name="204580254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580254">(Jul 21 2020 at 17:53)</a>:</h4>
<p>at this point I would probably look at what the LLVM code is doing in the area of code that emits this error you're getting</p>



<a name="204580381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580381">(Jul 21 2020 at 17:54)</a>:</h4>
<p>this happens during ./x.py build</p>



<a name="204580394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580394">(Jul 21 2020 at 17:54)</a>:</h4>
<p>i'm not sure how to inspect the IR during that.</p>



<a name="204580469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204580469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204580469">(Jul 21 2020 at 17:55)</a>:</h4>
<p>Would committing and pushing my code to a github branch help?</p>



<a name="204585765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204585765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204585765">(Jul 21 2020 at 18:39)</a>:</h4>
<p>I’m not suggesting to inspect the IR. I’m suggesting to look at the actual LLVM implementation around the place where this error is produced.</p>



<a name="204585812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204585812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204585812">(Jul 21 2020 at 18:39)</a>:</h4>
<p>This might tell you what exactly you're triggering and should inform how to deal with it.</p>



<a name="204585995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204585995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204585995">(Jul 21 2020 at 18:40)</a>:</h4>
<p>oh. Also I've been suggested to only really produce ptrauth bundles for rust programs, rather than rustc itself, if that's possible.</p>



<a name="204586516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204586516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204586516">(Jul 21 2020 at 18:45)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span></p>
<div class="codehilite"><pre><span></span><code>  <span class="c1">// Functions should never be ptrauth-called directly.</span>
  <span class="c1">// We could lower these to direct unauthenticated calls, but for that to</span>
  <span class="c1">// occur, there must have been a semantic mismatch somewhere leading to this</span>
  <span class="c1">// arguably incorrect IR.</span>
  <span class="k">if</span> <span class="p">(</span><span class="n">isa</span><span class="o">&lt;</span><span class="n">Function</span><span class="o">&gt;</span><span class="p">(</span><span class="n">CalleeV</span><span class="p">))</span>
    <span class="n">report_fatal_error</span><span class="p">(</span><span class="s">&quot;Cannot lower direct authenticated call to&quot;</span>
                       <span class="s">&quot; unauthenticated target&quot;</span><span class="p">);</span>
</code></pre></div>



<a name="204586995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204586995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204586995">(Jul 21 2020 at 18:48)</a>:</h4>
<p><a href="https://github.com/apple/llvm-project/blob/apple/stable/20200108/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp#L7718-L7756">https://github.com/apple/llvm-project/blob/apple/stable/20200108/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp#L7718-L7756</a></p>



<a name="204587198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587198">(Jul 21 2020 at 18:50)</a>:</h4>
<p>You’ll need to add some sort of a CLI argument for rustc vs regular programs.</p>



<a name="204587265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587265">(Jul 21 2020 at 18:51)</a>:</h4>
<p>but i'd much rather fix the problem at it's source</p>



<a name="204587296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587296">(Jul 21 2020 at 18:51)</a>:</h4>
<p>That was in response for "only really produce ptrauth bundles..."</p>



<a name="204587337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587337">(Jul 21 2020 at 18:52)</a>:</h4>
<p>ye</p>



<a name="204587398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587398">(Jul 21 2020 at 18:52)</a>:</h4>
<p>having a CLI argument that can be toggled is the proper way to go about it, rustc is not //that// hacky that it would need to know its building itself. And so it doesn’t.</p>



<a name="204587427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587427">(Jul 21 2020 at 18:52)</a>:</h4>
<p>i need to figure out why a FnPtr results in <code>isa&lt;Function&gt;(CalleeV)</code> being true, though.</p>



<a name="204587463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587463">(Jul 21 2020 at 18:53)</a>:</h4>
<p>I can imagine multiple causes, one of them being that LLVM's devirtualization optimization kicks in.</p>



<a name="204587515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587515">(Jul 21 2020 at 18:53)</a>:</h4>
<p>there's no way to see the IR it's producing, I don't think.</p>



<a name="204587545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587545">(Jul 21 2020 at 18:53)</a>:</h4>
<p>there are ways but they aren’t pleasant.</p>



<a name="204587750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587750">(Jul 21 2020 at 18:55)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> <a href="/user_uploads/4715/7KHwy9h8MHO_kQFPvP13gL-i/chrome_BdDVgD3PC1.png">chrome_BdDVgD3PC1.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/7KHwy9h8MHO_kQFPvP13gL-i/chrome_BdDVgD3PC1.png" title="chrome_BdDVgD3PC1.png"><img src="/user_uploads/4715/7KHwy9h8MHO_kQFPvP13gL-i/chrome_BdDVgD3PC1.png"></a></div>



<a name="204587824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587824">(Jul 21 2020 at 18:55)</a>:</h4>
<p>SelectionDAG happens after optimisation, pretty sure.</p>



<a name="204587979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587979">(Jul 21 2020 at 18:57)</a>:</h4>
<p>i'm going to try using println debugging in call/invoke</p>



<a name="204587998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204587998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204587998">(Jul 21 2020 at 18:57)</a>:</h4>
<p>probably will be useless but won't hurt</p>



<a name="204588723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204588723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204588723">(Jul 21 2020 at 19:03)</a>:</h4>
<p><a href="/user_uploads/4715/hUn24WSiU1NhQoRZ3xA1eOFB/chrome_g2JQ0tXxks.png">chrome_g2JQ0tXxks.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/hUn24WSiU1NhQoRZ3xA1eOFB/chrome_g2JQ0tXxks.png" title="chrome_g2JQ0tXxks.png"><img src="/user_uploads/4715/hUn24WSiU1NhQoRZ3xA1eOFB/chrome_g2JQ0tXxks.png"></a></div>



<a name="204588873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204588873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204588873">(Jul 21 2020 at 19:04)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> it might be because I haven't implemented the signing yet</p>



<a name="204589373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204589373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204589373">(Jul 21 2020 at 19:09)</a>:</h4>
<p>so here's what i think I need to do:<br>
initializing FnPtr VALUES when they're made using the <code>@llvm.ptrauth.sign</code> intrinisc</p>
<div class="codehilite"><pre><span></span><code><span class="k">declare</span> <span class="k">i64</span> <span class="vg">@llvm.ptrauth.sign.i64</span><span class="p">(</span><span class="k">i64</span> <span class="p">&lt;</span><span class="err">value</span><span class="p">&gt;,</span> <span class="k">i32</span> <span class="p">&lt;</span><span class="err">key</span><span class="p">&gt;,</span> <span class="k">i64</span> <span class="p">&lt;</span><span class="err">extra</span> <span class="err">data</span><span class="p">&gt;)</span>
</code></pre></div>



<a name="204589940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204589940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204589940">(Jul 21 2020 at 19:12)</a>:</h4>
<p>so i'll add these:</p>
<div class="codehilite"><pre><span></span><code><span class="w">        </span><span class="s">&quot;pacsigni64&quot;</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="s">&quot;llvm.ptrauth.sign.i64&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="s">&quot;pacauthi64&quot;</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="s">&quot;llvm.ptrauth.auth.i64&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="s">&quot;pacstripi64&quot;</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="s">&quot;llvm.ptrauth.strip.i64&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="s">&quot;pacresigni64&quot;</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="s">&quot;llvm.ptrauth.resign.i64&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="s">&quot;pacsigngenerici64&quot;</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="s">&quot;llvm.ptrauth.sign_generic.i64&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="s">&quot;pacblendi64&quot;</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="s">&quot;llvm.ptrauth.blend.i64&quot;</span><span class="p">,</span><span class="w"></span>
</code></pre></div>



<a name="204590025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204590025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204590025">(Jul 21 2020 at 19:13)</a>:</h4>
<p>... i don't know what else to do.</p>



<a name="204590186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204590186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204590186">(Jul 21 2020 at 19:14)</a>:</h4>
<p>I linked you to where reification (fndef -&gt; fnptr) happens yesterday.</p>



<a name="204590309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204590309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204590309">(Jul 21 2020 at 19:15)</a>:</h4>
<p>sorry</p>



<a name="204590324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204590324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204590324">(Jul 21 2020 at 19:15)</a>:</h4>
<p>What do you mean by "reification" btw?</p>



<a name="204590716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204590716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204590716">(Jul 21 2020 at 19:18)</a>:</h4>
<p>and that's in the psuedo-agonistic backend</p>



<a name="204590720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204590720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204590720">(Jul 21 2020 at 19:18)</a>:</h4>
<p>reification is turning something abstract (in this case a function definition) into something concrete (in this case a pointer to a function)</p>



<a name="204590795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204590795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204590795">(Jul 21 2020 at 19:18)</a>:</h4>
<p>meanwhile what I need to do is very much llvm-specific (emitting an intristic)</p>



<a name="204591023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204591023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204591023">(Jul 21 2020 at 19:20)</a>:</h4>
<p>I'm just very confused at the moment, sorry.</p>



<a name="204614666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204614666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204614666">(Jul 21 2020 at 23:24)</a>:</h4>
<p>Alright so here's what I think I need to do:</p>
<ul>
<li>Emit <code>llvm.ptrauth.sign.i64</code> intristics whenever a FnPtr is initialized in the IR</li>
<li>Emit a <code>ptrauth</code> bundle whenever a FnPtr is CALLED in the IR.</li>
</ul>
<p>I dunno how to do the first part.</p>



<a name="204614816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204614816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204614816">(Jul 21 2020 at 23:26)</a>:</h4>
<p>bare with me if i'm just being dumb and it's obvious</p>



<a name="204616022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204616022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204616022">(Jul 21 2020 at 23:45)</a>:</h4>
<p>An example of how LLVM intrinsic is called: <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/intrinsic.rs#L868">https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/intrinsic.rs#L868</a> which is then called in <code>_ssa</code> e.g. here: <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_ssa/mir/block.rs#L252">https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_ssa/mir/block.rs#L252</a>.</p>
<p>You’ll want at least one such intrinsic call around this area: <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_ssa/mir/rvalue.rs#L186">https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_ssa/mir/rvalue.rs#L186</a></p>



<a name="204616288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204616288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204616288">(Jul 21 2020 at 23:48)</a>:</h4>
<blockquote>
<p>produce ptrauth bundles for rust programs, rather than rustc itself</p>
</blockquote>
<p>I’d expect that you’d build rustc for target-without-auth and then build whatever program to target-with-auth. No need for a command line option that way.</p>



<a name="204616311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204616311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204616311">(Jul 21 2020 at 23:48)</a>:</h4>
<p>Effectively “cross-compiling”</p>



<a name="204616349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204616349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204616349">(Jul 21 2020 at 23:49)</a>:</h4>
<p>Will probably want a <code>-Z</code> or <code>-C</code> flag to control ptrauth one way or another.</p>



<a name="204616417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204616417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204616417">(Jul 21 2020 at 23:50)</a>:</h4>
<p>but yeah, "cross" build is another sensible option.</p>



<a name="204616585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204616585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204616585">(Jul 21 2020 at 23:52)</a>:</h4>
<p>It might just be <code>-C target-feature ptrauth</code></p>



<a name="204617423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204617423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204617423">(Jul 22 2020 at 00:04)</a>:</h4>
<p>Yeah, makes sense, but I should still be able to compile rustc itself as "proof" that it works.</p>



<a name="204617655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204617655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204617655">(Jul 22 2020 at 00:08)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> but wait, around that area in rvalue, i don't think the pointer has been turned into a Value yet?</p>



<a name="204617707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204617707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204617707">(Jul 22 2020 at 00:09)</a>:</h4>
<p>or a u64 or whatever</p>



<a name="204617761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204617761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204617761">(Jul 22 2020 at 00:10)</a>:</h4>
<p>it calls <code>bx.get_fn_addr</code> which generates the instruction to produce a pointer to the function.</p>



<a name="204617770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204617770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204617770">(Jul 22 2020 at 00:10)</a>:</h4>
<p>OOH, yeah. Thanks</p>



<a name="204617784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204617784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204617784">(Jul 22 2020 at 00:10)</a>:</h4>
<p>you could technically add the call to the intrinsic somewhere deeper in the callstack here</p>



<a name="204617794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204617794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204617794">(Jul 22 2020 at 00:10)</a>:</h4>
<p>like in the <code>get_fn_addr</code> itself or whatever it ends up calling.</p>



<a name="204617886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204617886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204617886">(Jul 22 2020 at 00:12)</a>:</h4>
<p>So,</p>
<div class="codehilite"><pre><span></span><code><span class="w">    </span><span class="k">fn</span> <span class="nf">pac_sign</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span>: <span class="nc">Self</span>::<span class="n">Value</span><span class="p">,</span><span class="w"> </span><span class="n">key</span>: <span class="kt">u32</span><span class="p">,</span><span class="w"> </span><span class="n">discrim</span>: <span class="kt">u64</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Value</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">fnname</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">get_intrinsic</span><span class="p">(</span><span class="o">&amp;</span><span class="p">(</span><span class="s">&quot;llvm.ptrauth.sign.i64&quot;</span><span class="p">));</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="n">call</span><span class="p">(</span><span class="n">fnname</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u32</span><span class="p">(</span><span class="n">key</span><span class="p">),</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u64</span><span class="p">(</span><span class="n">discrim</span><span class="p">)],</span><span class="w"> </span><span class="nb">None</span><span class="p">,</span><span class="w"> </span><span class="kc">false</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="204619525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204619525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204619525">(Jul 22 2020 at 00:42)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error: failed to parse bitcode for LTO module: Invalid cast (Producer: &#39;LLVM10.0.0-rust-dev&#39; Reader: &#39;LLVM 10.0.0-rust-dev&#39;)

error: aborting due to previous error

error: could not compile `backtrace`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to parse bitcode for LTO module: Invalid cast (Producer: &#39;LLVM10.0.0-rust-dev&#39; Reader: &#39;LLVM 10.0.0-rust-dev&#39;)

error: aborting due to previous error

error: failed to parse bitcode for LTO module: Invalid cast (Producer: &#39;LLVM10.0.0-rust-dev&#39; Reader: &#39;LLVM 10.0.0-rust-dev&#39;)
</code></pre></div>



<a name="204620465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204620465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204620465">(Jul 22 2020 at 00:56)</a>:</h4>
<p>looks like its getting further along at least.</p>



<a name="204620553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204620553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204620553">(Jul 22 2020 at 00:58)</a>:</h4>
<p>The "LLVM10.0.0-rust-dev" looks somewhat suspect, but that's pretty much all I have in terms of guesses.</p>



<a name="204622908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204622908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204622908">(Jul 22 2020 at 01:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/How.20to.20get.20rustc.20to.20generate.20LLVM.20IR.20differently.3F/near/204620553">said</a>:</p>
<blockquote>
<p>The "LLVM10.0.0-rust-dev" looks somewhat suspect, but that's pretty much all I have in terms of guesses.</p>
</blockquote>
<div class="codehilite"><pre><span></span><code># When building llvm, this configures what is being appended to the version.
# The default is &quot;-rust-$version-$channel&quot;, except for dev channel where rustc
# version number is omitted. To use LLVM version as is, provide an empty string.
#version-suffix = &quot;-rust-dev&quot;
</code></pre></div>



<a name="204622983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204622983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204622983">(Jul 22 2020 at 01:47)</a>:</h4>
<p>still, is there any way to see the LLVM IR that's being generated?</p>



<a name="204622984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204622984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204622984">(Jul 22 2020 at 01:47)</a>:</h4>
<p>or did i forget it</p>



<a name="204626524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204626524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204626524">(Jul 22 2020 at 03:12)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span><br>
<a href="/user_uploads/4715/dtlOYrrdQM3dAuyQaJhgr1ZS/chrome_UWFBecIgyT.png">chrome_UWFBecIgyT.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/dtlOYrrdQM3dAuyQaJhgr1ZS/chrome_UWFBecIgyT.png" title="chrome_UWFBecIgyT.png"><img src="/user_uploads/4715/dtlOYrrdQM3dAuyQaJhgr1ZS/chrome_UWFBecIgyT.png"></a></div>



<a name="204627691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204627691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204627691">(Jul 22 2020 at 03:41)</a>:</h4>
<p><a href="/user_uploads/4715/YG4_FR2sVfie3aQoVl5oOZv2/Code_9wt9WpSh55.png">Code_9wt9WpSh55.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/YG4_FR2sVfie3aQoVl5oOZv2/Code_9wt9WpSh55.png" title="Code_9wt9WpSh55.png"><img src="/user_uploads/4715/YG4_FR2sVfie3aQoVl5oOZv2/Code_9wt9WpSh55.png"></a></div>



<a name="204627695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204627695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204627695">(Jul 22 2020 at 03:41)</a>:</h4>
<p>well um, it's progress?</p>



<a name="204627786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204627786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204627786">(Jul 22 2020 at 03:43)</a>:</h4>
<p>it's std instead of backtrace failing now. that's further along.</p>



<a name="204628148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204628148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204628148">(Jul 22 2020 at 03:53)</a>:</h4>
<p><a href="https://github.com/Crabapple-iOS/rust/commit/8c214d7b21e1627f3a2abea68ddab42d4aa29625">https://github.com/Crabapple-iOS/rust/commit/8c214d7b21e1627f3a2abea68ddab42d4aa29625</a></p>



<a name="204628161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204628161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204628161">(Jul 22 2020 at 03:53)</a>:</h4>
<p>there's my code ^^^</p>



<a name="204679448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204679448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204679448">(Jul 22 2020 at 15:15)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> are you sure that the reification is the only way FnPtrs are created?</p>



<a name="204679952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204679952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204679952">(Jul 22 2020 at 15:17)</a>:</h4>
<p>That ought to be the case for user code at least, but at least std could be obtaining pointers to functions from external sources and codegen could also be generating its own function pointers that do not necessarily relate to user code.</p>



<a name="204680761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204680761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204680761">(Jul 22 2020 at 15:24)</a>:</h4>
<p>Yeah, I'd guess std is doing something weird. Where could these be generated at in codegen?</p>



<a name="204681131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204681131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204681131">(Jul 22 2020 at 15:26)</a>:</h4>
<p>No idea, sorry.</p>



<a name="204681179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204681179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204681179">(Jul 22 2020 at 15:26)</a>:</h4>
<p>Any way to look at the IR being generated for std?</p>



<a name="204681277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204681277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204681277">(Jul 22 2020 at 15:27)</a>:</h4>
<p>I guess it's probably better to just make PAC not be generated in rustc.</p>



<a name="204682443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204682443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204682443">(Jul 22 2020 at 15:35)</a>:</h4>
<p>i'll make it a target feature ig</p>



<a name="204685865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204685865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204685865">(Jul 22 2020 at 16:00)</a>:</h4>
<p>ha</p>



<a name="204685877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204685877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204685877">(Jul 22 2020 at 16:01)</a>:</h4>
<p>it worked i guess?</p>



<a name="204685883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204685883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204685883">(Jul 22 2020 at 16:01)</a>:</h4>
<p><code>%22 = call i64 @llvm.ptrauth.sign.i64(i64 ptrtoint (i1 (%"objc::runtime::Sel"*, %"core::fmt::Formatter"*)* @"_ZN55_$LT$objc..runtime..Sel$u20$as$u20$core..fmt..Debug$GT$3fmt17h6bea5d1d34e30595E" to i64), i32 0, i64 0)</code></p>



<a name="204686650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204686650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204686650">(Jul 22 2020 at 16:06)</a>:</h4>
<p>good news: it compiles</p>



<a name="204686659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204686659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204686659">(Jul 22 2020 at 16:06)</a>:</h4>
<p>bad news: it crashes on my iPhone</p>



<a name="204701594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204701594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204701594">(Jul 22 2020 at 18:08)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> is there any way to inspect the LLVM IR of libstd/etc?</p>



<a name="204702096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204702096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204702096">(Jul 22 2020 at 18:12)</a>:</h4>
<p>actually</p>



<a name="204702117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204702117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204702117">(Jul 22 2020 at 18:12)</a>:</h4>
<p>libstd is somehow still getting PACced</p>



<a name="204702126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204702126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204702126">(Jul 22 2020 at 18:12)</a>:</h4>
<p>or well the call to it is</p>



<a name="204703586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204703586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204703586">(Jul 22 2020 at 18:24)</a>:</h4>
<p>oh.</p>



<a name="204703603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204703603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204703603">(Jul 22 2020 at 18:24)</a>:</h4>
<p>"everything has to be PAC or nothing"</p>



<a name="204704645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204704645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204704645">(Jul 22 2020 at 18:32)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> Would you know if libstd is obtaining external pointers (aka not going through reify-ing and being signed)?</p>



<a name="204706808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204706808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204706808">(Jul 22 2020 at 18:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312033">aspen</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204701594">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> is there any way to inspect the LLVM IR of libstd/etc?</p>
</blockquote>
<p>You can use <code>--emit llvm-ir</code> as rustc argument while compiling libstd</p>



<a name="204707054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204707054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204707054">(Jul 22 2020 at 18:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312033">aspen</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204704645">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> Would you know if libstd is obtaining external pointers (aka not going through reify-ing and being signed)?</p>
</blockquote>
<p>Take a look at the <code>core::fmt</code> module. It does crazy stuff with pointers to implement dynamic dispatch without actually using trait objects. Maybe the problem is somewhere there?</p>



<a name="204707403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204707403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204707403">(Jul 22 2020 at 18:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312033">aspen</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204686659">said</a>:</p>
<blockquote>
<p>bad news: it crashes on my iPhone</p>
</blockquote>
<p>Can you attach a debugger using XCode to get a backtrace?</p>



<a name="204707624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204707624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204707624">(Jul 22 2020 at 18:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204707054">said</a>:</p>
<blockquote>
<p>Take a look at the <code>core::fmt</code> module. It does crazy stuff with pointers to implement dynamic dispatch without actually using trait objects.</p>
</blockquote>
<p>Ugh. This also bit us in AVR land.</p>



<a name="204707805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204707805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204707805">(Jul 22 2020 at 18:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116155">Jake Goulding</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204707624">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204707054">said</a>:</p>
<blockquote>
<p>Take a look at the <code>core::fmt</code> module. It does crazy stuff with pointers to implement dynamic dispatch without actually using trait objects.</p>
</blockquote>
<p>Ugh. This also bit us in AVR land.</p>
</blockquote>
<p>funnily enough, core::fmt is what crashed on my iPhone</p>



<a name="204707870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204707870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204707870">(Jul 22 2020 at 18:56)</a>:</h4>
<p>also i have a backtrace</p>



<a name="204707924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204707924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204707924">(Jul 22 2020 at 18:57)</a>:</h4>
<p>it's a pain to get it off my phone so gimme a second</p>



<a name="204708069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204708069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204708069">(Jul 22 2020 at 18:58)</a>:</h4>
<p>Ok, the other thing I would have suggested would be <code>libstd/sys/unix/weak.rs</code>, which does <code>transmute_copy(dlsym() as usize)</code> where the target type is often a funciton pointer.</p>



<a name="204708116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204708116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204708116">(Jul 22 2020 at 18:58)</a>:</h4>
<p>here, <a href="https://ghostbin.co/paste/ds27r">https://ghostbin.co/paste/ds27r</a></p>



<a name="204708287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204708287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204708287">(Jul 22 2020 at 18:59)</a>:</h4>
<p>altho that's likely because "PAC-less libstd, PAC binary"</p>



<a name="204708689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204708689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204708689">(Jul 22 2020 at 19:02)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> how would I ptrauth sign the function pointers in <a href="http://weak.rs">weak.rs</a> / core fmt stuff?</p>



<a name="204709407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709407">(Jul 22 2020 at 19:08)</a>:</h4>
<p>For fmt: does transmuting from one signature to the other affect signing?</p>



<a name="204709426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709426">(Jul 22 2020 at 19:09)</a>:</h4>
<p>For weak: does dlsym return a signed pointer or not?</p>



<a name="204709434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709434">(Jul 22 2020 at 19:09)</a>:</h4>
<p>i'm just using 0 as the key for everything rn</p>



<a name="204709463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709463">(Jul 22 2020 at 19:09)</a>:</h4>
<p>and yeah dlsym does return a signed pointer</p>



<a name="204709481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709481">(Jul 22 2020 at 19:09)</a>:</h4>
<p>wait does it, lemme ask</p>



<a name="204709585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709585">(Jul 22 2020 at 19:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204709407">said</a>:</p>
<blockquote>
<p>For fmt: does transmuting from one signature to the other affect signing?</p>
</blockquote>
<p>wait what do you mean by this</p>



<a name="204709600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709600">(Jul 22 2020 at 19:10)</a>:</h4>
<p>If so then both should technically work.</p>



<a name="204709686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709686">(Jul 22 2020 at 19:11)</a>:</h4>
<p>Does <code>transmute::&lt;fn(), fn(usize)&gt;(fun)(1)</code> work assuming that the abi allows it? Or does it require the function pointer to be signed differently?</p>



<a name="204709753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709753">(Jul 22 2020 at 19:12)</a>:</h4>
<p>the main issue is that "Cannot lower direct authenticated call to unauthenticated target" in libstd</p>
<div class="codehilite"><pre><span></span><code>  <span class="c1">// Functions should never be ptrauth-called directly.</span>
  <span class="c1">// We could lower these to direct unauthenticated calls, but for that to</span>
  <span class="c1">// occur, there must have been a semantic mismatch somewhere leading to this</span>
  <span class="c1">// arguably incorrect IR.</span>
  <span class="k">if</span> <span class="p">(</span><span class="n">isa</span><span class="o">&lt;</span><span class="n">Function</span><span class="o">&gt;</span><span class="p">(</span><span class="n">CalleeV</span><span class="p">))</span>
    <span class="n">report_fatal_error</span><span class="p">(</span><span class="s">&quot;Cannot lower direct authenticated call to&quot;</span>
                       <span class="s">&quot; unauthenticated target&quot;</span><span class="p">);</span>
</code></pre></div>



<a name="204709786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709786">(Jul 22 2020 at 19:12)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> also dlsym doesn't return a signed pointer, the sig would be added when it's casted to a function</p>



<a name="204709845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709845">(Jul 22 2020 at 19:13)</a>:</h4>
<p><code>weak.rs</code> doesn't cast, it transmutes, which is the only way to go from <code>usize</code> to <code>fn()</code>.</p>



<a name="204709968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709968">(Jul 22 2020 at 19:14)</a>:</h4>
<p>well, to have an <code>usize</code> of a function you will need to obtain the function pointer at some point anyway</p>



<a name="204709975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204709975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204709975">(Jul 22 2020 at 19:14)</a>:</h4>
<p>Can you recompile libstd without optimizations and preferably with <code>-Z symbol-mangling-version=v0</code>? That would give a much more helpful backtrace.</p>



<a name="204710006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710006">(Jul 22 2020 at 19:14)</a>:</h4>
<p>i'd prefer to get libstd to compile with PAC, which would hopefully not cause that crash</p>



<a name="204710028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710028">(Jul 22 2020 at 19:15)</a>:</h4>
<p>the cast from <code>usize</code>s to <code>fn()</code> doesn’t matter in that respect. The casts from <code>fn() {concrete}</code> to <code>fn()</code> or <code>usize</code> do.</p>



<a name="204710054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710054">(Jul 22 2020 at 19:15)</a>:</h4>
<p>as i'm 99% sure that crash is caused by mixing PAC user code with non-PAC core/std code</p>



<a name="204710062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710062">(Jul 22 2020 at 19:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204709968">said</a>:</p>
<blockquote>
<p>well, to have an <code>usize</code> of a function you will need to obtain the function pointer at some point anyway</p>
</blockquote>
<p>That <code>usize</code> is returned by <code>dlsym</code>, which returns unsigned pointers.</p>



<a name="204710116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710116">(Jul 22 2020 at 19:15)</a>:</h4>
<p>there's no way to logically do anything with that then</p>



<a name="204710130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710130">(Jul 22 2020 at 19:15)</a>:</h4>
<p>how does dlsym work in clang</p>



<a name="204710203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710203">(Jul 22 2020 at 19:16)</a>:</h4>
<p>let me get the IR output of an example I was given of dlsym?</p>



<a name="204710205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710205">(Jul 22 2020 at 19:16)</a>:</h4>
<p>if it doesn’t there, it won’t here.</p>



<a name="204710239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710239">(Jul 22 2020 at 19:16)</a>:</h4>
<p>not so much interested in the IR as to whether it works at all.</p>



<a name="204710272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710272">(Jul 22 2020 at 19:17)</a>:</h4>
<p>yeah but the IR will show if it's being signed or not</p>



<a name="204710291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710291">(Jul 22 2020 at 19:17)</a>:</h4>
<p>signing would need to happen _inside_ of dlsym though.</p>



<a name="204710309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710309">(Jul 22 2020 at 19:17)</a>:</h4>
<p><a href="https://googleprojectzero.blogspot.com/2020/01/remote-iphone-exploitation-part-3.html">https://googleprojectzero.blogspot.com/2020/01/remote-iphone-exploitation-part-3.html</a></p>
<blockquote>
<p>With PAC enabled, dlsym will sign returned function pointers with context zero (as no sensible context value is available to the caller) before returning them</p>
</blockquote>



<a name="204710378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710378">(Jul 22 2020 at 19:18)</a>:</h4>
<p>possibly somewhere inside of the actual loader-linker, not even in the dlsym itself.</p>



<a name="204710431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710431">(Jul 22 2020 at 19:18)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="c">; Function Attrs: noinline nounwind optnone ssp uwtable</span>
<span class="k">define</span> <span class="k">i32</span> <span class="vg">@main</span><span class="p">()</span> <span class="vg">#0</span> <span class="p">{</span>
  <span class="nv nv-Anonymous">%1</span> <span class="p">=</span> <span class="k">alloca</span> <span class="k">i8</span><span class="p">*,</span> <span class="k">align</span> <span class="m">8</span>
  <span class="nv nv-Anonymous">%2</span> <span class="p">=</span> <span class="k">alloca</span> <span class="k">i32</span> <span class="p">(</span><span class="k">i8</span><span class="p">*)*,</span> <span class="k">align</span> <span class="m">8</span>
  <span class="nv nv-Anonymous">%3</span> <span class="p">=</span> <span class="k">call</span> <span class="k">i8</span><span class="p">*</span> <span class="vg">@dlsym</span><span class="p">(</span><span class="k">i8</span><span class="p">*</span> <span class="k">inttoptr</span> <span class="p">(</span><span class="k">i64</span> <span class="m">-2</span> <span class="k">to</span> <span class="k">i8</span><span class="p">*),</span> <span class="k">i8</span><span class="p">*</span> <span class="k">getelementptr</span> <span class="k">inbounds</span> <span class="p">([</span><span class="m">5</span> <span class="k">x</span> <span class="k">i8</span><span class="p">],</span> <span class="p">[</span><span class="m">5</span> <span class="k">x</span> <span class="k">i8</span><span class="p">]*</span> <span class="vg">@.str</span><span class="p">,</span> <span class="k">i32</span> <span class="m">0</span><span class="p">,</span> <span class="k">i32</span> <span class="m">0</span><span class="p">))</span>
  <span class="k">store</span> <span class="k">i8</span><span class="p">*</span> <span class="nv nv-Anonymous">%3</span><span class="p">,</span> <span class="k">i8</span><span class="p">**</span> <span class="nv nv-Anonymous">%1</span><span class="p">,</span> <span class="k">align</span> <span class="m">8</span>
  <span class="nv nv-Anonymous">%4</span> <span class="p">=</span> <span class="k">load</span> <span class="k">i8</span><span class="p">*,</span> <span class="k">i8</span><span class="p">**</span> <span class="nv nv-Anonymous">%1</span><span class="p">,</span> <span class="k">align</span> <span class="m">8</span>
  <span class="nv nv-Anonymous">%5</span> <span class="p">=</span> <span class="k">bitcast</span> <span class="k">i8</span><span class="p">*</span> <span class="nv nv-Anonymous">%4</span> <span class="k">to</span> <span class="k">i32</span> <span class="p">(</span><span class="k">i8</span><span class="p">*)*</span>
  <span class="k">store</span> <span class="k">i32</span> <span class="p">(</span><span class="k">i8</span><span class="p">*)*</span> <span class="nv nv-Anonymous">%5</span><span class="p">,</span> <span class="k">i32</span> <span class="p">(</span><span class="k">i8</span><span class="p">*)**</span> <span class="nv nv-Anonymous">%2</span><span class="p">,</span> <span class="k">align</span> <span class="m">8</span>
  <span class="nv nv-Anonymous">%6</span> <span class="p">=</span> <span class="k">load</span> <span class="k">i32</span> <span class="p">(</span><span class="k">i8</span><span class="p">*)*,</span> <span class="k">i32</span> <span class="p">(</span><span class="k">i8</span><span class="p">*)**</span> <span class="nv nv-Anonymous">%2</span><span class="p">,</span> <span class="k">align</span> <span class="m">8</span>
  <span class="nv nv-Anonymous">%7</span> <span class="p">=</span> <span class="k">call</span> <span class="k">i32</span> <span class="nv nv-Anonymous">%6</span><span class="p">(</span><span class="k">i8</span><span class="p">*</span> <span class="k">getelementptr</span> <span class="k">inbounds</span> <span class="p">([</span><span class="m">3</span> <span class="k">x</span> <span class="k">i8</span><span class="p">],</span> <span class="p">[</span><span class="m">3</span> <span class="k">x</span> <span class="k">i8</span><span class="p">]*</span> <span class="vg">@.str.1</span><span class="p">,</span> <span class="k">i32</span> <span class="m">0</span><span class="p">,</span> <span class="k">i32</span> <span class="m">0</span><span class="p">))</span> <span class="p">[</span> <span class="s">&quot;ptrauth&quot;</span><span class="p">(</span><span class="k">i32</span> <span class="m">0</span><span class="p">,</span> <span class="k">i64</span> <span class="m">0</span><span class="p">)</span> <span class="p">]</span>
  <span class="k">ret</span> <span class="k">i32</span> <span class="m">0</span>
</code></pre></div>



<a name="204710516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710516">(Jul 22 2020 at 19:19)</a>:</h4>
<p>what does "PAC enabled" mean in terms of the loader and the C standard library?</p>



<a name="204710583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710583">(Jul 22 2020 at 19:20)</a>:</h4>
<p>does it mean a different loader needs to be used? Different <code>libc</code>?</p>



<a name="204710601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710601">(Jul 22 2020 at 19:20)</a>:</h4>
<p><a href="/user_uploads/4715/FcpV8zDlkTWyXQ66RV59DsUi/chrome_66yeTObajR.png">chrome_66yeTObajR.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/FcpV8zDlkTWyXQ66RV59DsUi/chrome_66yeTObajR.png" title="chrome_66yeTObajR.png"><img src="/user_uploads/4715/FcpV8zDlkTWyXQ66RV59DsUi/chrome_66yeTObajR.png"></a></div>



<a name="204710605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710605">(Jul 22 2020 at 19:20)</a>:</h4>
<p>some flag on the binary?</p>



<a name="204710637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710637">(Jul 22 2020 at 19:20)</a>:</h4>
<p>Can you compile <code>libstd</code> with <code>--emit llvm-ir</code> and then <code>grep call | grep ptrauth</code> on the ir to narrow down the possible sources of the signed direct call?</p>



<a name="204710646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710646">(Jul 22 2020 at 19:20)</a>:</h4>
<p>with Mach-O binaries, cpu subtype 0x2 (ARM64E) usually means PAC-enabled</p>



<a name="204710834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710834">(Jul 22 2020 at 19:22)</a>:</h4>
<p>in that case do as <span class="user-mention" data-user-id="133247">@bjorn3</span> suggested – compile libstd directly with rustc, <code>--emit llvm-ir</code> and spelunk from there. I don't actually have you a step-by-step for this though as x.py is not exactly the most pleasant thing to pass things through or for figuring out what rustc or flags are actually used to run the failing invocation.</p>



<a name="204710963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204710963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204710963">(Jul 22 2020 at 19:23)</a>:</h4>
<p>/me remembers the short life of <code>--on-fail</code>...</p>



<a name="204711035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204711035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204711035">(Jul 22 2020 at 19:24)</a>:</h4>
<p>You can pass <code>-vv</code> to x.py to get the exact rustc invocation for libstd and then run that command again with <code>--emit llvm-ir</code> instead of the existing <code>--emit</code> flag.</p>



<a name="204711086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204711086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204711086">(Jul 22 2020 at 19:24)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> is there no longer a wrapper rustc that will just fail because there's no variables it requires in environment?</p>



<a name="204711123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204711123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204711123">(Jul 22 2020 at 19:25)</a>:</h4>
<p>If you pass <code>-vv</code> that wrapper will print the actual rustc invocation.</p>



<a name="204711137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204711137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204711137">(Jul 22 2020 at 19:25)</a>:</h4>
<p>got it.</p>



<a name="204711798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204711798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204711798">(Jul 22 2020 at 19:31)</a>:</h4>
<p><a href="/user_uploads/4715/a0Sf876wulrGEDb3DNyPIXDa/chrome_w2cDEl9c9t.png">chrome_w2cDEl9c9t.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/a0Sf876wulrGEDb3DNyPIXDa/chrome_w2cDEl9c9t.png" title="chrome_w2cDEl9c9t.png"><img src="/user_uploads/4715/a0Sf876wulrGEDb3DNyPIXDa/chrome_w2cDEl9c9t.png"></a></div>



<a name="204712444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204712444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204712444">(Jul 22 2020 at 19:36)</a>:</h4>
<p>transmuting to a fnptr should probably just always strip and sign</p>



<a name="204713457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204713457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204713457">(Jul 22 2020 at 19:45)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> <code>thread 'main' panicked at 'RUSTC_STAGE was not set: NotPresent', src/bootstrap/bin/rustc.rs:48:17</code></p>



<a name="204713466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204713466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204713466">(Jul 22 2020 at 19:45)</a>:</h4>
<p>can't just copy-paste the -vv command</p>



<a name="204713820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204713820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204713820">(Jul 22 2020 at 19:49)</a>:</h4>
<p>ok there</p>



<a name="204713976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204713976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204713976">(Jul 22 2020 at 19:50)</a>:</h4>
<p><a href="/user_uploads/4715/nt0b3d8b6Bol_3hQgncEazp-/std-41925f8d57880a33.ll">std-41925f8d57880a33.ll</a>  <span class="user-mention" data-user-id="123586">@nagisa</span>  <span class="user-mention" data-user-id="133247">@bjorn3</span></p>



<a name="204714170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204714170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204714170">(Jul 22 2020 at 19:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312033">aspen</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204712444">said</a>:</p>
<blockquote>
<p>transmuting to a fnptr should probably just always strip and sign</p>
</blockquote>
<p>I disagree, mostly because the whole point of signing function pointers in the first place gets lost.</p>



<a name="204714812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204714812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204714812">(Jul 22 2020 at 19:58)</a>:</h4>
<p>is that IR file I posted helpful?</p>



<a name="204714974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204714974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204714974">(Jul 22 2020 at 19:59)</a>:</h4>
<p>there are signed calls to non-function-pointer things in there, mostly related to thread locals.</p>



<a name="204715073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204715073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204715073">(Jul 22 2020 at 20:00)</a>:</h4>
<p>oh, hm</p>



<a name="204715112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204715112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204715112">(Jul 22 2020 at 20:00)</a>:</h4>
<p>the ptrauth bundle should only be added to things that are a FnPtr</p>



<a name="204715153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204715153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204715153">(Jul 22 2020 at 20:00)</a>:</h4>
<p><span class="user-mention" data-user-id="312033">@aspen</span> can you remove the <code>-Copt-level</code> / <code>-O</code> flags and make another llvm-ir dump (please compress it with at least gzip too)</p>



<a name="204715183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204715183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204715183">(Jul 22 2020 at 20:01)</a>:</h4>
<p>sure</p>



<a name="204715593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204715593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204715593">(Jul 22 2020 at 20:04)</a>:</h4>
<p><a href="/user_uploads/4715/X1h7kGFgf1YIi6bg5ZRhbfuU/std-41925f8d57880a33.ll.gz">std-41925f8d57880a33.ll.gz</a> with opt level 0</p>



<a name="204716002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716002">(Jul 22 2020 at 20:07)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> it might be trait related?</p>



<a name="204716118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716118">(Jul 22 2020 at 20:08)</a>:</h4>
<p><a href="/user_uploads/4715/kbcQYQ1ESoRbyYARUESeNjAl/chrome_X2nOLXs6hR.png">chrome_X2nOLXs6hR.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/kbcQYQ1ESoRbyYARUESeNjAl/chrome_X2nOLXs6hR.png" title="chrome_X2nOLXs6hR.png"><img src="/user_uploads/4715/kbcQYQ1ESoRbyYARUESeNjAl/chrome_X2nOLXs6hR.png"></a></div>



<a name="204716324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716324">(Jul 22 2020 at 20:10)</a>:</h4>
<p>could be</p>



<a name="204716369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716369">(Jul 22 2020 at 20:10)</a>:</h4>
<p>looking at unopt llvm ir will tell</p>



<a name="204716395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716395">(Jul 22 2020 at 20:10)</a>:</h4>
<p>yeah that's what i just posted / where he got that from</p>



<a name="204716415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716415">(Jul 22 2020 at 20:10)</a>:</h4>
<p><code>__getit</code> is part of the tls implementation in libstd</p>



<a name="204716462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716462">(Jul 22 2020 at 20:11)</a>:</h4>
<p>thread locals seem to be a common factor here.</p>



<a name="204716599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716599">(Jul 22 2020 at 20:12)</a>:</h4>
<p><a href="/user_uploads/4715/xHyR6iNlojOdgzx_GKfhnH5x/chrome_Eo00ks3yQQ.png">chrome_Eo00ks3yQQ.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/xHyR6iNlojOdgzx_GKfhnH5x/chrome_Eo00ks3yQQ.png" title="chrome_Eo00ks3yQQ.png"><img src="/user_uploads/4715/xHyR6iNlojOdgzx_GKfhnH5x/chrome_Eo00ks3yQQ.png"></a></div>



<a name="204716615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716615">(Jul 22 2020 at 20:12)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/23744c84d9c0f8e4e870edb983f1ad6d33449c34/src/libstd/thread/local.rs#L262">https://github.com/rust-lang/rust/blob/23744c84d9c0f8e4e870edb983f1ad6d33449c34/src/libstd/thread/local.rs#L262</a></p>



<a name="204716672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716672">(Jul 22 2020 at 20:12)</a>:</h4>
<p>this is originally an indirect call, but it gets optimized to a direct call</p>



<a name="204716719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716719">(Jul 22 2020 at 20:13)</a>:</h4>
<p>hm, so that needs to get signed.</p>



<a name="204716724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716724">(Jul 22 2020 at 20:13)</a>:</h4>
<p>huh, not exactly a trait vtable</p>



<a name="204716807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716807">(Jul 22 2020 at 20:13)</a>:</h4>
<p>rather its <code>unsafe fn</code></p>



<a name="204716865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716865">(Jul 22 2020 at 20:14)</a>:</h4>
<p>"where rustc builds constants that contain function pointers, like these @allocNNN symbols with __getit implementations in them, you might need another compiler modification to create signed constant values"</p>



<a name="204716982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204716982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204716982">(Jul 22 2020 at 20:15)</a>:</h4>
<p><code>LocalKey::new</code> is called at runtime: <a href="https://github.com/rust-lang/rust/blob/23744c84d9c0f8e4e870edb983f1ad6d33449c34/src/libstd/thread/local.rs#L179">https://github.com/rust-lang/rust/blob/23744c84d9c0f8e4e870edb983f1ad6d33449c34/src/libstd/thread/local.rs#L179</a></p>



<a name="204717063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717063">(Jul 22 2020 at 20:15)</a>:</h4>
<p><a href="https://github.com/apple/llvm-project/blob/apple/master/llvm/docs/PointerAuth.md#authenticated-global-relocation">https://github.com/apple/llvm-project/blob/apple/master/llvm/docs/PointerAuth.md#authenticated-global-relocation</a></p>



<a name="204717081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717081">(Jul 22 2020 at 20:16)</a>:</h4>
<p><span class="user-mention" data-user-id="312033">@aspen</span> this could be the <code>mir::CastKind::Pointer(PointerCast::UnsafeFnPointer)</code> cast in <code>src/librustc_codegen_ssa/mir/rvalue.rs</code></p>



<a name="204717130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717130">(Jul 22 2020 at 20:16)</a>:</h4>
<p>but can’t really check right now</p>



<a name="204717131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717131">(Jul 22 2020 at 20:16)</a>:</h4>
<p>It is LLVM that then specializes the <code>try_with</code> method to call the given function pointer as a direct call.</p>



<a name="204717179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717179">(Jul 22 2020 at 20:16)</a>:</h4>
<p>either way there's a reification going on here as well, its just not from <code>fn() {concrete}</code> to <code>fn()</code> but from <code>unsafe fn() {concrete}</code> to <code>unsafe fn()</code>.</p>



<a name="204717195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717195">(Jul 22 2020 at 20:16)</a>:</h4>
<p>should be trivial to make a self-contained reproducer too.</p>



<a name="204717292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717292">(Jul 22 2020 at 20:17)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> yeah this is exactly the same thing they hit when they originally tried to build without signing any function pointers and just calling with ptrauth</p>



<a name="204717324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717324">(Jul 22 2020 at 20:17)</a>:</h4>
<p>The problem here is that a indirect call gets turned into a direct call by LLVM without removing the "ptrauth" metadata from the call.</p>



<a name="204717418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717418">(Jul 22 2020 at 20:18)</a>:</h4>
<p>it actually happened earlier (in backtrace) when not signing anything</p>



<a name="204717551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204717551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204717551">(Jul 22 2020 at 20:19)</a>:</h4>
<p>there's a global for authenticated relocations / signed pointers</p>
<div class="codehilite"><pre><span></span><code><span class="vg">@fp.ptrauth</span> <span class="p">=</span> <span class="k">constant</span> <span class="p">{</span> <span class="k">i8</span><span class="p">*,</span> <span class="k">i32</span><span class="p">,</span> <span class="k">i64</span><span class="p">,</span> <span class="k">i64</span> <span class="p">}</span>
                       <span class="p">{</span> <span class="k">i8</span><span class="p">*</span> <span class="p">&lt;</span><span class="err">value</span><span class="p">&gt;,</span>
                         <span class="k">i32</span> <span class="p">&lt;</span><span class="err">key</span><span class="p">&gt;,</span>
                         <span class="k">i64</span> <span class="p">&lt;</span><span class="err">address</span> <span class="err">discriminat</span><span class="k">or</span><span class="p">&gt;,</span>
                         <span class="k">i64</span> <span class="p">&lt;</span><span class="err">integer</span> <span class="err">discriminat</span><span class="k">or</span><span class="p">&gt;</span>
                       <span class="p">},</span> <span class="k">section</span> <span class="s">&quot;llvm.ptrauth&quot;</span>
</code></pre></div>



<a name="204718236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204718236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204718236">(Jul 22 2020 at 20:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204716982">said</a>:</p>
<blockquote>
<p><code>LocalKey::new</code> is called at runtime: <a href="https://github.com/rust-lang/rust/blob/23744c84d9c0f8e4e870edb983f1ad6d33449c34/src/libstd/thread/local.rs#L179">https://github.com/rust-lang/rust/blob/23744c84d9c0f8e4e870edb983f1ad6d33449c34/src/libstd/thread/local.rs#L179</a></p>
</blockquote>
<p>my bad, it is called in a static initializer</p>



<a name="204718526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204718526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204718526">(Jul 22 2020 at 20:27)</a>:</h4>
<p>oh. That could mean changes in miri or whatever part of it we have in rustc for consteval might be necessary.</p>



<a name="204718564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204718564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204718564">(Jul 22 2020 at 20:27)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="124288">@oli</span></p>



<a name="204718605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204718605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204718605">(Jul 22 2020 at 20:28)</a>:</h4>
<p>signing immediates in <code>mir::CastKind::Pointer(PointerCast::UnsafeFnPointer)</code> didn't help seemingly.</p>



<a name="204718749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204718749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204718749">(Jul 22 2020 at 20:29)</a>:</h4>
<p><a href="/user_uploads/4715/eKspjXejCZF6x-TGRykm30x3/chrome_Dq6SduiRy5.png">chrome_Dq6SduiRy5.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/eKspjXejCZF6x-TGRykm30x3/chrome_Dq6SduiRy5.png" title="chrome_Dq6SduiRy5.png"><img src="/user_uploads/4715/eKspjXejCZF6x-TGRykm30x3/chrome_Dq6SduiRy5.png"></a></div>



<a name="204719151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204719151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204719151">(Jul 22 2020 at 20:33)</a>:</h4>
<p>You will need to change <a href="https://github.com/rust-lang/rust/blob/e22b61bff0bdd08be7665607cb7be3748c8a35d2/src/librustc_codegen_llvm/common.rs#L259">https://github.com/rust-lang/rust/blob/e22b61bff0bdd08be7665607cb7be3748c8a35d2/src/librustc_codegen_llvm/common.rs#L259</a> for signed pointers in consts and statics.</p>



<a name="204719391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204719391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204719391">(Jul 22 2020 at 20:35)</a>:</h4>
<p>I guess more broadly speaking anywhere where <code>get_fn_addr</code> is invoked you might want to do it</p>



<a name="204719406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204719406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204719406">(Jul 22 2020 at 20:35)</a>:</h4>
<p>or perhaps move signing to <code>get_fn_addr</code> instead?</p>



<a name="204719560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204719560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204719560">(Jul 22 2020 at 20:37)</a>:</h4>
<p>That screenshot says that runtime and static pointer signing happens differently, but <code>get_fn_addr</code> is used for both.</p>



<a name="204720103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720103">(Jul 22 2020 at 20:41)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204719406">said</a>:</p>
<blockquote>
<p>or perhaps move signing to <code>get_fn_addr</code> instead?</p>
</blockquote>
<p>can you access the <code>Bx</code> from CodegenCx?</p>



<a name="204720211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720211">(Jul 22 2020 at 20:42)</a>:</h4>
<p><code>cx.bx</code> I think.</p>



<a name="204720297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720297">(Jul 22 2020 at 20:43)</a>:</h4>
<p>No, only the opposite way. A builder has access to a CodegenCx, but a CodegenCx can be used by multiple builders.</p>



<a name="204720349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720349">(Jul 22 2020 at 20:43)</a>:</h4>
<p>since well, signing uses ptrtoint/inttoptr</p>



<a name="204720436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720436">(Jul 22 2020 at 20:44)</a>:</h4>
<p>What is the link in the screenshot?</p>



<a name="204720447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720447">(Jul 22 2020 at 20:44)</a>:</h4>
<p><a href="https://github.com/apple/llvm-project/blob/apple/master/llvm/docs/PointerAuth.md#authenticated-global-relocation">https://github.com/apple/llvm-project/blob/apple/master/llvm/docs/PointerAuth.md#authenticated-global-relocation</a></p>



<a name="204720494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720494">(Jul 22 2020 at 20:44)</a>:</h4>
<p><span class="user-mention" data-user-id="312033">@aspen</span> src/librustc_codegen_llvm/callee.rs in get_fn you can just use raw LLVM API at this point.</p>



<a name="204720538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720538">(Jul 22 2020 at 20:45)</a>:</h4>
<p>(<code>get_fn</code> is called directly by <code>get_fn_addr</code>)</p>



<a name="204720658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720658">(Jul 22 2020 at 20:46)</a>:</h4>
<p>though idk if you'll have the basic block to codegen into?</p>



<a name="204720674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720674">(Jul 22 2020 at 20:46)</a>:</h4>
<p>hm</p>



<a name="204720692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720692">(Jul 22 2020 at 20:46)</a>:</h4>
<p>for constants you wouldn’t have anything like that anyway</p>



<a name="204720784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720784">(Jul 22 2020 at 20:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Pointer.20authentication.20support.20in.20Rust's.20LLVM.20codegen/near/204720658">said</a>:</p>
<blockquote>
<p>though idk if you'll have the basic block to codegen into?</p>
</blockquote>
<p>that is called the builder.</p>



<a name="204720848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204720848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204720848">(Jul 22 2020 at 20:47)</a>:</h4>
<p>for constants the pointer signing works by having a special type and putting it in a certain section.</p>



<a name="204721769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204721769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204721769">(Jul 22 2020 at 20:55)</a>:</h4>
<p>ye and how would i do that</p>



<a name="204722710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204722710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204722710">(Jul 22 2020 at 21:02)</a>:</h4>
<p><a href="/user_uploads/4715/2C2KHUy8Gvi_6xmu52ExzBCq/chrome_DKKkWhvRu5.png">chrome_DKKkWhvRu5.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/2C2KHUy8Gvi_6xmu52ExzBCq/chrome_DKKkWhvRu5.png" title="chrome_DKKkWhvRu5.png"><img src="/user_uploads/4715/2C2KHUy8Gvi_6xmu52ExzBCq/chrome_DKKkWhvRu5.png"></a></div>



<a name="204722920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204722920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204722920">(Jul 22 2020 at 21:04)</a>:</h4>
<p>i need to figure out how to create global constants in that format</p>



<a name="204722969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204722969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204722969">(Jul 22 2020 at 21:05)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/8926bb497d9b127eb318aea5aed0e745d8381591/src/librustc_codegen_llvm/debuginfo/gdb.rs#L50">https://github.com/rust-lang/rust/blob/8926bb497d9b127eb318aea5aed0e745d8381591/src/librustc_codegen_llvm/debuginfo/gdb.rs#L50</a></p>



<a name="204723018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723018">(Jul 22 2020 at 21:05)</a>:</h4>
<p>So search for calls to <code>define_global</code>?</p>



<a name="204723147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723147">(Jul 22 2020 at 21:06)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/9e92106d457abd14f82adc29e7f2496861e07916/src/librustc_codegen_llvm/consts.rs#L81">https://github.com/rust-lang/rust/blob/9e92106d457abd14f82adc29e7f2496861e07916/src/librustc_codegen_llvm/consts.rs#L81</a></p>



<a name="204723188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723188">(Jul 22 2020 at 21:07)</a>:</h4>
<p>the other link was for setting the section name. this one for creating a const struct.</p>



<a name="204723197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723197">(Jul 22 2020 at 21:07)</a>:</h4>
<p>ah</p>



<a name="204723538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723538">(Jul 22 2020 at 21:11)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> am i starting this right?</p>
<div class="codehilite"><pre><span></span><code><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">const_struct</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">cx</span><span class="p">.</span><span class="n">const_struct</span><span class="p">(</span><span class="o">&amp;</span><span class="n">llvals</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">cx</span><span class="p">.</span><span class="n">tcx</span><span class="p">.</span><span class="n">sess</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">options</span><span class="p">.</span><span class="n">use_pac</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">section_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">b&quot;llvm.ptrauth</span><span class="se">\0</span><span class="s">&quot;</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">llvm</span>::<span class="n">LLVMSetSection</span><span class="p">(</span><span class="n">const_struct</span><span class="p">,</span><span class="w"> </span><span class="n">section_name</span><span class="p">.</span><span class="n">as_ptr</span><span class="p">().</span><span class="n">cast</span><span class="p">());</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="n">const_struct</span><span class="w"></span>
</code></pre></div>



<a name="204723733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723733">(Jul 22 2020 at 21:13)</a>:</h4>
<p>wait</p>



<a name="204723738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723738">(Jul 22 2020 at 21:13)</a>:</h4>
<p>The if should be around everything.</p>



<a name="204723753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723753">(Jul 22 2020 at 21:13)</a>:</h4>
<p>Is <code>const_alloc_to_llvm</code> the right place to do this, even?</p>



<a name="204723834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723834">(Jul 22 2020 at 21:14)</a>:</h4>
<p>I'm confused.</p>



<a name="204723836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723836">(Jul 22 2020 at 21:14)</a>:</h4>
<p>No, <a href="https://github.com/rust-lang/rust/blob/e22b61bff0bdd08be7665607cb7be3748c8a35d2/src/librustc_codegen_llvm/common.rs#L259">https://github.com/rust-lang/rust/blob/e22b61bff0bdd08be7665607cb7be3748c8a35d2/src/librustc_codegen_llvm/common.rs#L259</a> is</p>



<a name="204723857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204723857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204723857">(Jul 22 2020 at 21:14)</a>:</h4>
<p>oh, my bad</p>



<a name="204724062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204724062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204724062">(Jul 22 2020 at 21:17)</a>:</h4>
<p>If I understand the document correctly for PAC you need to make a const struct with the right format and section, then load the pointer field from that struct and return it.</p>



<a name="204732595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204732595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204732595">(Jul 22 2020 at 22:59)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> this is prolly wrong but a start?</p>
<div class="codehilite"><pre><span></span><code><span class="w">                    </span><span class="n">GlobalAlloc</span>::<span class="n">Function</span><span class="p">(</span><span class="n">fn_instance</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                        </span><span class="kd">let</span><span class="w"> </span><span class="n">fn_addr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">get_fn_addr</span><span class="p">(</span><span class="n">fn_instance</span><span class="p">);</span><span class="w"></span>
<span class="w">                        </span><span class="kd">let</span><span class="w"> </span><span class="n">fn_addr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">tcx</span><span class="p">.</span><span class="n">sess</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">options</span><span class="p">.</span><span class="n">use_pac</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">section_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">b&quot;llvm.ptrauth</span><span class="se">\0</span><span class="s">&quot;</span><span class="p">;</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">llvals</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vec</span><span class="o">!</span><span class="p">[</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_bitcast</span><span class="p">(</span><span class="n">fn_addr</span><span class="p">,</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">type_i8p_ext</span><span class="p">(</span><span class="n">base_addr_space</span><span class="p">)),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u32</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u64</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u64</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span><span class="w"></span>
<span class="w">                            </span><span class="p">];</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">const_struct</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">const_struct</span><span class="p">(</span><span class="o">&amp;</span><span class="n">llvals</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span><span class="p">);</span><span class="w"></span>
<span class="w">                            </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                                </span><span class="n">llvm</span>::<span class="n">LLVMSetSection</span><span class="p">(</span><span class="n">const_struct</span><span class="p">,</span><span class="w"> </span><span class="n">section_name</span><span class="p">.</span><span class="n">as_ptr</span><span class="p">().</span><span class="n">cast</span><span class="p">());</span><span class="w"></span>
<span class="w">                            </span><span class="p">}</span><span class="w"></span>
<span class="w">                            </span><span class="n">const_struct</span><span class="w"></span>
<span class="w">                        </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                            </span><span class="n">fn_addr</span><span class="w"></span>
<span class="w">                        </span><span class="p">};</span><span class="w"></span>
<span class="w">                        </span><span class="p">(</span><span class="n">fn_addr</span><span class="p">,</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">data_layout</span><span class="p">().</span><span class="n">instruction_address_space</span><span class="p">)</span><span class="w"></span>
<span class="w">                    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="204739130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204739130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204739130">(Jul 23 2020 at 00:33)</a>:</h4>
<div class="codehilite"><pre><span></span><code>Invalid bitcast
i64* bitcast (&lt;{ i8*, i32, i64, i64 }&gt; &lt;{ i8* bitcast (i1 (i64*, %&quot;fmt::Formatter&quot;*)* @_ZN4core3ops8function6FnOnce9call_once17h308963fb3a4be439E.llvm.770221769397704865 to i8*), i32 0, i64 0, i64 0 }&gt; to i64*)
in function _ZN4core3fmt10ArgumentV110from_usize17h7c95b3070fdad98eE
LLVM ERROR: Broken function found, compilation aborted!
</code></pre></div>



<a name="204751325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204751325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204751325">(Jul 23 2020 at 01:03)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> i messed up the constant signing thing but idk how?</p>



<a name="204763914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204763914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204763914">(Jul 23 2020 at 06:18)</a>:</h4>
<p>You need to extract the pointer field from the struct.</p>



<a name="204828069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204828069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204828069">(Jul 23 2020 at 17:34)</a>:</h4>
<p>huh?</p>



<a name="204828257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204828257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204828257">(Jul 23 2020 at 17:36)</a>:</h4>
<p><code>const_struct</code> is has type <code>{i8*, i32, i64, i64}</code>, not a function pointer. You need to get the first field of <code>const_struct</code> and cast it cack to a function pointer.</p>



<a name="204828368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204828368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204828368">(Jul 23 2020 at 17:37)</a>:</h4>
<p>Ohhh. Uh, how do I do that?</p>



<a name="204828503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204828503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204828503">(Jul 23 2020 at 17:38)</a>:</h4>
<p><a href="https://llvm.org/docs/LangRef.html#constant-expressions">https://llvm.org/docs/LangRef.html#constant-expressions</a></p>



<a name="204828607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204828607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204828607">(Jul 23 2020 at 17:39)</a>:</h4>
<p><code>extractvalue</code> + <code>bitcast</code></p>



<a name="204828622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204828622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204828622">(Jul 23 2020 at 17:39)</a>:</h4>
<p>thanks</p>



<a name="204828989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204828989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204828989">(Jul 23 2020 at 17:42)</a>:</h4>
<p><code>llvm::LLVMConstExtractValue</code> and <code>cx.const_bitcast</code> it seems</p>



<a name="204830439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204830439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204830439">(Jul 23 2020 at 17:52)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> LLVMConstExtractValue takes 2 indexes?</p>



<a name="204830581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204830581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204830581">(Jul 23 2020 at 17:53)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">llvm</span>::<span class="n">LLVMConstExtractValue</span><span class="p">(</span><span class="o">&amp;</span><span class="n">const_struct</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="bp">self</span><span class="p">.</span><span class="n">const_bitcast</span><span class="p">(</span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="n">llty</span><span class="p">)</span><span class="w"></span>
</code></pre></div>



<a name="204830953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204830953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204830953">(Jul 23 2020 at 17:56)</a>:</h4>
<p>it might be </p>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">llvm</span>::<span class="n">LLVMConstExtractValue</span><span class="p">(</span><span class="o">&amp;</span><span class="n">const_struct</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">llvals</span><span class="p">.</span><span class="n">as_ptr</span><span class="p">(),</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
</code></pre></div>



<a name="204833690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204833690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204833690">(Jul 23 2020 at 18:17)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> i got no clue what to pass as IdxList in LLVMConstExtractValue</p>



<a name="204833738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204833738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204833738">(Jul 23 2020 at 18:17)</a>:</h4>
<p><span class="user-mention" data-user-id="312033">@aspen</span> Seems that there is already a wrapper called <code>const_get_elt</code>: <a href="https://github.com/rust-lang/rust/blob/e22b61bff0bdd08be7665607cb7be3748c8a35d2/src/librustc_codegen_llvm/common.rs#L134">https://github.com/rust-lang/rust/blob/e22b61bff0bdd08be7665607cb7be3748c8a35d2/src/librustc_codegen_llvm/common.rs#L134</a></p>



<a name="204833814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204833814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204833814">(Jul 23 2020 at 18:18)</a>:</h4>
<p>ah</p>



<a name="204833859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204833859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204833859">(Jul 23 2020 at 18:18)</a>:</h4>
<p>i didn't know what that did</p>



<a name="204837236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204837236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204837236">(Jul 23 2020 at 18:41)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="w">                    </span><span class="n">GlobalAlloc</span>::<span class="n">Function</span><span class="p">(</span><span class="n">fn_instance</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                        </span><span class="kd">let</span><span class="w"> </span><span class="n">fn_addr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">get_fn_addr</span><span class="p">(</span><span class="n">fn_instance</span><span class="p">);</span><span class="w"></span>
<span class="w">                        </span><span class="kd">let</span><span class="w"> </span><span class="n">fn_addr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">tcx</span><span class="p">.</span><span class="n">sess</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">options</span><span class="p">.</span><span class="n">use_pac</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">section_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">b&quot;llvm.ptrauth</span><span class="se">\0</span><span class="s">&quot;</span><span class="p">;</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">llvals</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vec</span><span class="o">!</span><span class="p">[</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_bitcast</span><span class="p">(</span><span class="n">fn_addr</span><span class="p">,</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">type_i8p</span><span class="p">()),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u32</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u64</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u64</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span><span class="w"></span>
<span class="w">                            </span><span class="p">];</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">const_struct</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">const_struct</span><span class="p">(</span><span class="o">&amp;</span><span class="n">llvals</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span><span class="p">);</span><span class="w"></span>
<span class="w">                            </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                                </span><span class="n">llvm</span>::<span class="n">LLVMSetSection</span><span class="p">(</span><span class="n">const_struct</span><span class="p">,</span><span class="w"> </span><span class="n">section_name</span><span class="p">.</span><span class="n">as_ptr</span><span class="p">().</span><span class="n">cast</span><span class="p">());</span><span class="w"></span>
<span class="w">                            </span><span class="p">}</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">const_get_elt</span><span class="p">(</span><span class="n">const_struct</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">                            </span><span class="bp">self</span><span class="p">.</span><span class="n">const_bitcast</span><span class="p">(</span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="n">llty</span><span class="p">)</span><span class="w"></span>
<span class="w">                        </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                            </span><span class="n">fn_addr</span><span class="w"></span>
<span class="w">                        </span><span class="p">};</span><span class="w"></span>
<span class="w">                        </span><span class="p">(</span><span class="n">fn_addr</span><span class="p">,</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">data_layout</span><span class="p">().</span><span class="n">instruction_address_space</span><span class="p">)</span><span class="w"></span>
<span class="w">                    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="204837254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204837254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204837254">(Jul 23 2020 at 18:41)</a>:</h4>
<p><code>(signal: 11, SIGSEGV: invalid memory reference)</code></p>



<a name="204837452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204837452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204837452">(Jul 23 2020 at 18:43)</a>:</h4>
<p>backtrace? to see which call is wrong.</p>



<a name="204837520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204837520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204837520">(Jul 23 2020 at 18:43)</a>:</h4>
<p>there is no backtrace</p>



<a name="204837529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204837529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204837529">(Jul 23 2020 at 18:43)</a>:</h4>
<p>rustc straight-up segfaults.</p>



<a name="204839772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204839772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204839772">(Jul 23 2020 at 19:00)</a>:</h4>
<p>It's the <code>const_get_elt</code> causing a segfault.</p>



<a name="204844162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204844162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204844162">(Jul 23 2020 at 19:36)</a>:</h4>
<p>Can you try a debugger? Or maybe enabling LLVM assertions helps?</p>



<a name="204844647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204844647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204844647">(Jul 23 2020 at 19:41)</a>:</h4>
<p>how to enable LLVM assertions?</p>



<a name="204844810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204844810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204844810">(Jul 23 2020 at 19:42)</a>:</h4>
<p>In the <code>[llvm]</code> section of <code>config.toml</code> set <code>assertions</code> to <code>true</code>. This will require rebuilding LLVM though, so using a debugger to get a backtrace may be much quicker.</p>



<a name="204844847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204844847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204844847">(Jul 23 2020 at 19:43)</a>:</h4>
<p>well just running rustc by itself hangs</p>



<a name="204844928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204844928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204844928">(Jul 23 2020 at 19:44)</a>:</h4>
<p>You can try getting a core dump: <a href="https://stackoverflow.com/questions/9412156/how-to-generate-core-dumps-in-mac-os-x">https://stackoverflow.com/questions/9412156/how-to-generate-core-dumps-in-mac-os-x</a></p>



<a name="204846529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204846529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204846529">(Jul 23 2020 at 19:58)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> </p>
<div class="codehilite"><pre><span></span><code>(lldb) bt
* thread #1, stop reason = signal SIGSTOP
  * frame #0: 0x00007fff66aa09de libsystem_kernel.dylib`__ulock_wait + 10
    frame #1: 0x00007fff66b5b6de libsystem_pthread.dylib`_pthread_join + 358
    frame #2: 0x000000010f045c20 libstd-0df675e1e2e78542.dylib`std::sys::unix::thread::Thread::join::h8bbc2457eb2c1f1b + 16
    frame #3: 0x0000000109471903 librustc_driver-3d9795c7c19d0d03.dylib`std::thread::JoinHandle$LT$T$GT$::join::h3042544f480aa241 + 35
    frame #4: 0x0000000109454b5d librustc_driver-3d9795c7c19d0d03.dylib`rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::h262735b5b5e37072 + 461
    frame #5: 0x00000001094677b0 librustc_driver-3d9795c7c19d0d03.dylib`rustc_interface::interface::run_compiler::h0e2fd9601134eb12 + 112
    frame #6: 0x00000001094783a0 librustc_driver-3d9795c7c19d0d03.dylib`rustc_driver::run_compiler::h6f7f421a8a344173 + 5616
    frame #7: 0x000000010947296c librustc_driver-3d9795c7c19d0d03.dylib`_$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::hd292fb43f1b65c9d + 108
    frame #8: 0x0000000109468801 librustc_driver-3d9795c7c19d0d03.dylib`std::panicking::try::h014b44a8bd0fd60c + 17
    frame #9: 0x00000001093b40b5 librustc_driver-3d9795c7c19d0d03.dylib`rustc_driver::catch_with_exit_code::h8abe84d4c4935835 + 21
    frame #10: 0x000000010947df7b librustc_driver-3d9795c7c19d0d03.dylib`rustc_driver::main::h4cd388b66fc85381 + 43
    frame #11: 0x0000000109346f3e rustc`rustc_binary::main::h5e083a268a490654 + 14
    frame #12: 0x0000000109346f06 rustc`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::ha6a5aaa37343f0ab + 6
    frame #13: 0x000000010f075785 libstd-0df675e1e2e78542.dylib`std::panicking::try::hb9c5d0feb4ab7b8d + 21
    frame #14: 0x000000010f069719 libstd-0df675e1e2e78542.dylib`std::rt::lang_start_internal::he8c3ba1f11e99b99 + 137
    frame #15: 0x0000000109346f69 rustc`main + 41
    frame #16: 0x00007fff669693d5 libdyld.dylib`start + 1
    frame #17: 0x00007fff669693d5 libdyld.dylib`start + 1
</code></pre></div>



<a name="204849374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204849374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204849374">(Jul 23 2020 at 20:24)</a>:</h4>
<p>Please use <code>bt all</code> to get a backtrace for all threads. That backtrace was just for the main thread, which almost immediately spawns a new thread for the compilation to happen in. (to prevent tls variables to conflict with potential other rustc compilations started from the same thread)</p>



<a name="204849547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204849547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204849547">(Jul 23 2020 at 20:26)</a>:</h4>
<p>whoops, thanks. I was just following the stackoverflow thread that you linked!</p>



<a name="204849955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204849955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204849955">(Jul 23 2020 at 20:30)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> <a href="https://ghostbin.co/paste/mzbx5">https://ghostbin.co/paste/mzbx5</a></p>



<a name="204850598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204850598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204850598">(Jul 23 2020 at 20:36)</a>:</h4>
<p>I can't quite figure out which thread is the crashing one. Can you try again with <code>-Ccodegen-units=1</code> to ensure that only one thread runs LLVM at a time?</p>



<a name="204852096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204852096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204852096">(Jul 23 2020 at 20:51)</a>:</h4>
<p>sure</p>



<a name="204854878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204854878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204854878">(Jul 23 2020 at 21:20)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> <a href="https://ghostbin.co/paste/5ydne">https://ghostbin.co/paste/5ydne</a></p>



<a name="204855552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204855552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204855552">(Jul 23 2020 at 21:28)</a>:</h4>
<div class="codehilite"><pre><span></span><code>    frame #0: 0x000000011217c41e librustc_driver-3d9795c7c19d0d03.dylib`llvm::DataLayout::getTypeSizeInBits(llvm::Type*) const + 14
    frame #1: 0x00000001131b8788 librustc_driver-3d9795c7c19d0d03.dylib`llvm::ConstantFoldLoadThroughBitcast(llvm::Constant*, llvm::Type*, llvm::DataLayout const&amp;) + 56
</code></pre></div>



<a name="204855582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204855582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204855582">(Jul 23 2020 at 21:28)</a>:</h4>
<p>hm?</p>



<a name="204855992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204855992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204855992">(Jul 23 2020 at 21:33)</a>:</h4>
<p>I don't know why it wouldn't be allowed.</p>



<a name="204856055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204856055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204856055">(Jul 23 2020 at 21:34)</a>:</h4>
<p><a href="/user_uploads/4715/yDLSBhzpUS70H-Xvb91OWOop/chrome_Ikeg8MbXkw.png">chrome_Ikeg8MbXkw.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/yDLSBhzpUS70H-Xvb91OWOop/chrome_Ikeg8MbXkw.png" title="chrome_Ikeg8MbXkw.png"><img src="/user_uploads/4715/yDLSBhzpUS70H-Xvb91OWOop/chrome_Ikeg8MbXkw.png"></a></div>



<a name="204856526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204856526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204856526">(Jul 23 2020 at 21:38)</a>:</h4>
<p>You sent the old code before the <code>const_get_elt</code> and <code>const_bitcast</code> addition.</p>



<a name="204856539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204856539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204856539">(Jul 23 2020 at 21:39)</a>:</h4>
<p>oops</p>



<a name="204856813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204856813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204856813">(Jul 23 2020 at 21:42)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> i did send the newer code later, I was more trying to point to what he said about initializers</p>



<a name="204856952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204856952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204856952">(Jul 23 2020 at 21:43)</a>:</h4>
<p>I think he was saying that you missed <code>const_get_elt</code> in the code you sent.</p>



<a name="204856977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204856977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204856977">(Jul 23 2020 at 21:43)</a>:</h4>
<p><a href="/user_uploads/4715/XdZMR_73t5FZ1R-AzPzGaA1t/chrome_0sI8216nq8.png">chrome_0sI8216nq8.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/XdZMR_73t5FZ1R-AzPzGaA1t/chrome_0sI8216nq8.png" title="chrome_0sI8216nq8.png"><img src="/user_uploads/4715/XdZMR_73t5FZ1R-AzPzGaA1t/chrome_0sI8216nq8.png"></a></div>



<a name="204856992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204856992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204856992">(Jul 23 2020 at 21:43)</a>:</h4>
<p>this is my current code:</p>
<div class="codehilite"><pre><span></span><code><span class="w">                    </span><span class="n">GlobalAlloc</span>::<span class="n">Function</span><span class="p">(</span><span class="n">fn_instance</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                        </span><span class="kd">let</span><span class="w"> </span><span class="n">fn_addr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">get_fn_addr</span><span class="p">(</span><span class="n">fn_instance</span><span class="p">);</span><span class="w"></span>
<span class="w">                        </span><span class="kd">let</span><span class="w"> </span><span class="n">fn_addr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">tcx</span><span class="p">.</span><span class="n">sess</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">target</span><span class="p">.</span><span class="n">options</span><span class="p">.</span><span class="n">use_pac</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">section_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">b&quot;llvm.ptrauth</span><span class="se">\0</span><span class="s">&quot;</span><span class="p">;</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">llvals</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vec</span><span class="o">!</span><span class="p">[</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_bitcast</span><span class="p">(</span><span class="n">fn_addr</span><span class="p">,</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">type_i8p</span><span class="p">()),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u32</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u64</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">const_u64</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span><span class="w"></span>
<span class="w">                            </span><span class="p">];</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">const_struct</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">const_struct</span><span class="p">(</span><span class="o">&amp;</span><span class="n">llvals</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span><span class="p">);</span><span class="w"></span>
<span class="w">                            </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                                </span><span class="n">llvm</span>::<span class="n">LLVMSetSection</span><span class="p">(</span><span class="n">const_struct</span><span class="p">,</span><span class="w"> </span><span class="n">section_name</span><span class="p">.</span><span class="n">as_ptr</span><span class="p">().</span><span class="n">cast</span><span class="p">());</span><span class="w"></span>
<span class="w">                            </span><span class="p">}</span><span class="w"></span>
<span class="w">                            </span><span class="kd">let</span><span class="w"> </span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">const_get_elt</span><span class="p">(</span><span class="n">const_struct</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">                            </span><span class="bp">self</span><span class="p">.</span><span class="n">const_bitcast</span><span class="p">(</span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="n">llty</span><span class="p">)</span><span class="w"></span>
<span class="w">                        </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                            </span><span class="n">fn_addr</span><span class="w"></span>
<span class="w">                        </span><span class="p">};</span><span class="w"></span>
<span class="w">                        </span><span class="p">(</span><span class="n">fn_addr</span><span class="p">,</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">data_layout</span><span class="p">().</span><span class="n">instruction_address_space</span><span class="p">)</span><span class="w"></span>
<span class="w">                    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="204857003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857003">(Jul 23 2020 at 21:43)</a>:</h4>
<p>this is what causes a segfault in rustc.</p>



<a name="204857199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857199">(Jul 23 2020 at 21:45)</a>:</h4>
<p>The segfault happens later during an optimiztion pass.</p>



<a name="204857254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857254">(Jul 23 2020 at 21:46)</a>:</h4>
<p>oh, hm.</p>



<a name="204857263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857263">(Jul 23 2020 at 21:46)</a>:</h4>
<p>so what might be the cause?</p>



<a name="204857276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857276">(Jul 23 2020 at 21:46)</a>:</h4>
<p>am i just doing this wrong?</p>



<a name="204857281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857281">(Jul 23 2020 at 21:46)</a>:</h4>
<p>The failing function is <a href="https://github.com/llvm/llvm-project/blob/f0634100cdc832605bff355330d2ccdb7f43842f/llvm/include/llvm/IR/DataLayout.h#L635">https://github.com/llvm/llvm-project/blob/f0634100cdc832605bff355330d2ccdb7f43842f/llvm/include/llvm/IR/DataLayout.h#L635</a></p>



<a name="204857328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857328">(Jul 23 2020 at 21:47)</a>:</h4>
<p>am I casting the struct wrong?</p>



<a name="204857329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857329">(Jul 23 2020 at 21:47)</a>:</h4>
<p>Is <code>bitcast</code> allowed for pointer -&gt; function pointer as opposed to the other way around?</p>



<a name="204857418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857418">(Jul 23 2020 at 21:48)</a>:</h4>
<p>I'm not sure, actually.</p>



<a name="204857438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857438">(Jul 23 2020 at 21:48)</a>:</h4>
<p>yes.</p>



<a name="204857443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857443">(Jul 23 2020 at 21:48)</a>:</h4>
<p>hm, weird then.</p>



<a name="204857500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857500">(Jul 23 2020 at 21:49)</a>:</h4>
<p>wait, what is <code>llty</code> in <code>scalar_to_backend</code>?</p>



<a name="204857512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857512">(Jul 23 2020 at 21:49)</a>:</h4>
<p>ok it's <code>cx.type_i8p_ext(address_space)</code></p>



<a name="204857610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857610">(Jul 23 2020 at 21:50)</a>:</h4>
<p>so the pointer is getting casted back to an i8p</p>



<a name="204857752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857752">(Jul 23 2020 at 21:52)</a>:</h4>
<p>i'm not sure if that's right?<br>
should I be using <code>const_ptrcast</code>?</p>



<a name="204857987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204857987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204857987">(Jul 23 2020 at 21:54)</a>:</h4>
<p>Isn't the type a function type and not a pointer for functions?</p>



<a name="204858010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858010">(Jul 23 2020 at 21:54)</a>:</h4>
<p>Honestly I've lost track of what's what.</p>



<a name="204858044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858044">(Jul 23 2020 at 21:54)</a>:</h4>
<p>this was the original goal:</p>
<div class="codehilite"><pre><span></span><code><span class="o">@</span><span class="n">fp</span><span class="p">.</span><span class="n">ptrauth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">constant</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kt">i8</span><span class="o">*</span><span class="p">,</span><span class="w"> </span><span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="kt">i64</span><span class="p">,</span><span class="w"> </span><span class="kt">i64</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">                       </span><span class="p">{</span><span class="w"> </span><span class="kt">i8</span><span class="o">*</span><span class="w"> </span><span class="o">&lt;</span><span class="n">value</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">                         </span><span class="kt">i32</span><span class="w"> </span><span class="o">&lt;</span><span class="n">key</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">                         </span><span class="kt">i64</span><span class="w"> </span><span class="o">&lt;</span><span class="n">address</span><span class="w"> </span><span class="n">discriminator</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">                         </span><span class="kt">i64</span><span class="w"> </span><span class="o">&lt;</span><span class="n">integer</span><span class="w"> </span><span class="n">discriminator</span><span class="o">&gt;</span><span class="w"></span>
<span class="w">                       </span><span class="p">},</span><span class="w"> </span><span class="n">section</span><span class="w"> </span><span class="s">&quot;llvm.ptrauth&quot;</span><span class="w"></span>
</code></pre></div>



<a name="204858062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858062">(Jul 23 2020 at 21:55)</a>:</h4>
<p>source: <a href="https://github.com/apple/llvm-project/blob/apple/master/llvm/docs/PointerAuth.md#authenticated-global-relocation">https://github.com/apple/llvm-project/blob/apple/master/llvm/docs/PointerAuth.md#authenticated-global-relocation</a></p>



<a name="204858333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858333">(Jul 23 2020 at 21:58)</a>:</h4>
<p>I think you got that part right, but to do something useful you need to get the pointer back out of the struct. That is where the problem probably lies.</p>



<a name="204858372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858372">(Jul 23 2020 at 21:59)</a>:</h4>
<p>Ok, so <code>let ptr = self.const_get_elt(const_struct, 0);</code></p>



<a name="204858376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858376">(Jul 23 2020 at 21:59)</a>:</h4>
<p>This gets us a pointer to a Value which is an <code>i8*</code></p>



<a name="204858394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858394">(Jul 23 2020 at 22:00)</a>:</h4>
<p>Or should, at least.</p>



<a name="204858496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858496">(Jul 23 2020 at 22:00)</a>:</h4>
<p>idk I can't use println from librustc_codegen_llvm to check</p>



<a name="204858514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858514">(Jul 23 2020 at 22:01)</a>:</h4>
<p>Yes, and that needs to be casted back to a function.</p>



<a name="204858536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858536">(Jul 23 2020 at 22:01)</a>:</h4>
<p>why can't you use println?</p>



<a name="204858543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858543">(Jul 23 2020 at 22:01)</a>:</h4>
<p>symbol errors?</p>



<a name="204858554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858554">(Jul 23 2020 at 22:01)</a>:</h4>
<p>something related to fmt, lemme check</p>



<a name="204858613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858613">(Jul 23 2020 at 22:02)</a>:</h4>
<p>Maybe I'm bitcasting to the wrong type?</p>



<a name="204858616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858616">(Jul 23 2020 at 22:02)</a>:</h4>
<p>As llty is <code>cx.type_i8p_ext(address_space)</code></p>



<a name="204858635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858635">(Jul 23 2020 at 22:02)</a>:</h4>
<p>And struct[0] is already an i8*</p>



<a name="204858879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858879">(Jul 23 2020 at 22:05)</a>:</h4>
<p>where do you get that type from?</p>



<a name="204858911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858911">(Jul 23 2020 at 22:05)</a>:</h4>
<p>This is where <code>scalar_to_backend</code> is called:</p>



<a name="204858917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858917">(Jul 23 2020 at 22:05)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="w">        </span><span class="n">llvals</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">cx</span><span class="p">.</span><span class="n">scalar_to_backend</span><span class="p">(</span><span class="w"></span>
<span class="w">            </span><span class="n">Pointer</span>::<span class="n">new</span><span class="p">(</span><span class="n">alloc_id</span><span class="p">,</span><span class="w"> </span><span class="n">Size</span>::<span class="n">from_bytes</span><span class="p">(</span><span class="n">ptr_offset</span><span class="p">)).</span><span class="n">into</span><span class="p">(),</span><span class="w"></span>
<span class="w">            </span><span class="o">&amp;</span><span class="n">Scalar</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">value</span>: <span class="nc">Primitive</span>::<span class="n">Pointer</span><span class="p">,</span><span class="w"> </span><span class="n">valid_range</span>: <span class="mi">0</span><span class="o">..=!</span><span class="mi">0</span><span class="w"> </span><span class="p">},</span><span class="w"></span>
<span class="w">            </span><span class="n">cx</span><span class="p">.</span><span class="n">type_i8p_ext</span><span class="p">(</span><span class="n">address_space</span><span class="p">),</span><span class="w"></span>
<span class="w">        </span><span class="p">));</span><span class="w"></span>
</code></pre></div>



<a name="204858927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858927">(Jul 23 2020 at 22:05)</a>:</h4>
<p>... nevermind it's also called from ssa</p>



<a name="204858928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858928">(Jul 23 2020 at 22:05)</a>:</h4>
<p>woops</p>



<a name="204858980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204858980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204858980">(Jul 23 2020 at 22:06)</a>:</h4>
<p><code>bx.immediate_backend_type(layout)</code><br>
<code>bx.scalar_pair_element_backend_type(layout, 0, true)</code></p>



<a name="204920576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204920576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204920576">(Jul 24 2020 at 14:16)</a>:</h4>
<p>is llty really the right thing to be casting to?</p>



<a name="204925682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204925682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204925682">(Jul 24 2020 at 14:54)</a>:</h4>
<p>I think it is</p>



<a name="204925743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204925743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204925743">(Jul 24 2020 at 14:55)</a>:</h4>
<p>weird, I don't understand this problem then</p>



<a name="204926281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204926281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204926281">(Jul 24 2020 at 14:59)</a>:</h4>
<p>Neither do I</p>



<a name="204965299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204965299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204965299">(Jul 24 2020 at 20:51)</a>:</h4>
<p>could we just attach lldb to rustc instead?</p>



<a name="204970390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204970390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204970390">(Jul 24 2020 at 21:48)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> </p>
<blockquote>
<p>what you want is ultimately for the IR to look like: <code>@allocNNN = global void()* (bitcast @foo
.ptrauth to void()*)</code></p>
</blockquote>



<a name="204992876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/204992876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#204992876">(Jul 25 2020 at 07:36)</a>:</h4>
<p>Sorry, out of ideas</p>



<a name="205064232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/205064232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#205064232">(Jul 26 2020 at 19:30)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> </p>
<blockquote>
<p>when a global initializer includes an unauthenticated function pointer, that's represented using the llvm::Function<em>, which is a subclass of llvm::Constant</em> that represents the pointer to the function. to make it an authenticated pointer instead, use the llvm::GlobalVariable* you created with the ptrauth info, but bitcast it to the function pointer type of the original llvm::Function*</p>
</blockquote>



<a name="205064295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/205064295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#205064295">(Jul 26 2020 at 19:32)</a>:</h4>
<p>If I understand that correctly the <code>const_get_elt</code> should be removed but the <code>const_bitcast</code> should be kept.</p>



<a name="205066428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/205066428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#205066428">(Jul 26 2020 at 20:37)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> </p>
<div class="codehilite"><pre><span></span><code>   Compiling rustc-std-workspace-core v1.99.0 (/Users/aleister/Code/rust/src/tools/rustc-std-workspace-core)
Invalid bitcast
i64 addrspace(7)* bitcast (&lt;{ i8*, i32, i64, i64 }&gt; &lt;{ i8* bitcast (i1 (i64*, %&quot;fmt::Formatter&quot;*)* @_ZN4core3ops8function6FnOnce9call_once17h308963fb3a4be439E.llvm.4526489033524205078 to i8*), i32 0, i64 0, i64 0 }&gt; to i64 addrspace(7)*)
in function _ZN4core3fmt10ArgumentV110from_usize17h7c95b3070fdad98eE
LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `core`.
</code></pre></div>



<a name="205066927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/205066927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#205066927">(Jul 26 2020 at 20:51)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> OH, I need to bitcast in <code>declare_global</code>!</p>



<a name="208451613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Pointer%20authentication%20support%20in%20Rust%27s%20LLVM%20codegen/near/208451613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aspen <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Pointer.20authentication.20support.20in.20Rust&#x27;s.20LLVM.20codegen.html#208451613">(Aug 29 2020 at 20:09)</a>:</h4>
<p>i have forgotten what i have even needed to do</p>
<p>maybe LLVM 11 will make this easier because apple master is 11</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>